Premium Only Content
Introducing CSS - Inline/External Styles (Cascading Style Sheets) - HTML Tutorial Series
Welcome back to our HTML Tutorial Series! Today, we’re going to enhance the styling of our HTML content by exploring inline styles and external stylesheets. But first, let’s tidy up our HTML structure. We’ll start by separating some of our content into individual paragraphs. Let’s dive in!
In our current HTML file we have a heading, a paragraph with some text, an image, and a link. To improve the structure, we’ll move the image into its own paragraph and separate the text into a new paragraph.
We’ve now separated the descriptive text and the image into their own paragraphs. This makes our HTML more organized and easier to manage.
Now that we’ve updated the structure, let’s add some inline styles. We’ll start by setting the image height to a maximum of 100 pixels and allowing its width to adjust automatically. We’ll also set the background color of the body and the text color.
Here, we’ve added inline styles directly to the body and img elements. The body background color is set to dark gray (#333), and the text color is set to white (#fff). The image’s maximum height is 100 pixels with its width set to auto.
Next, let’s move these inline styles into an external stylesheet. This approach is more scalable and makes it easier to manage styles across multiple pages.
We’ll create a new CSS file named styles.css in a public_html/css/ directory. In this file, we’ll define the same styles we applied inline.
This CSS file sets the body background color and text color, and applies styles to img elements.
Now, let’s link this stylesheet to our HTML file. We’ll remove the inline styles and include a link to our styles.css file in the head section.
We’ve added a "link" tag in the head section to include our external CSS file and removed the inline styles.
Let’s take a look at the result in the browser. As you can see, the styles are applied through the external stylesheet, keeping our HTML clean and organized.
That wraps up today’s tutorial! We’ve covered how to separate HTML content into distinct paragraphs and move styles from inline to an external stylesheet. Don’t forget to like, subscribe, and hit the notification bell for more web development tips. Thanks for watching!
-
1:28:13
Kim Iversen
15 hours agoCancelled Chef Pete Evans Exposes The One Change That Could End Big Food and Pharma
79K77 -
4:20:21
Nerdrotic
16 hours ago $77.13 earnedDaradevil Born Again, Comics Industry CRASH, Neu-Hollywood REBUILD | Friday Night Tights #337
236K49 -
1:32:34
Glenn Greenwald
12 hours agoThe Future of Gaza With Abubaker Abed; Journalist Sam Husseini On His Physical Expulsion From Blinken’s Briefing & Biden’s Gaza Legacy | System Update #391
120K91 -
1:34:48
Roseanne Barr
15 hours ago $24.01 earnedWe are so F*cking Punk Rock! with Drea de Matteo | The Roseanne Barr Podcast #83
93.7K79 -
1:08:20
Man in America
16 hours ago🇨🇳 RedNote: A CCP Trojan Horse Deceiving Americans? w/ Levi Browde
48.1K44 -
3:55:11
I_Came_With_Fire_Podcast
19 hours agoTrump SABOTAGE, LA FIRE CHIEF SUED, and BIDEN’S LAST F-U!
32.5K8 -
2:59:47
Joker Effect
10 hours agoUkraine in a video game? Hardest thing I have done. S.T.A.L.K.E.R.2 Heart of Chornobyl,
114K8 -
1:15:22
Flyover Conservatives
1 day agoEczema, Brain Fog, B.O., and Gas… Eating Steak and Butter Creates Ultimate Health Hack - Bella, Steak and Butter Gal | FOC Show
83.4K6 -
51:58
PMG
14 hours ago $3.51 earned"Can the Government Learn from Elon Musk’s 70% Labor Cut? A Deep Dive into Inefficient Agencies"
59.7K1 -
6:39:15
Amish Zaku
13 hours agoRumble Spartans #10 - New Year New Maps
50.2K3