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!
-
6:05
Blabbering Collector
18 hours agoRowling On Set, Bill Nighy To Join Cast, HBO Head Comments On Season 2 Of Harry Potter HBO!
12.4K3 -
57:44
TruthStream with Joe and Scott
2 days agoShe's of Love podcast & Joe:A co-Hosted interview, Mother and Daughter (300,000+Facebook page) Travel, Home School, Staying Grounded, Recreating oneself, SolarPunk #514
27.9K1 -
30:49
MetatronHistory
1 day agoThe Truth about Women Warriors Based on Facts, Evidence and Sources
28.3K12 -
2:59:08
FreshandFit
13 hours agoA Sugar Baby & A Feminist ALMOST Fight Each Other
259K56 -
6:24:23
SpartakusLIVE
11 hours agoFriday Night HYPE w/ YOUR King of Content
109K1 -
2:27:53
Laura Loomer
9 hours agoBREAKING: MTG Resigns From Congress, Mamdani Meets Trump
74.9K115 -
3:30:10
PandaSub2000
1 day agoDisney & Buzz Trivia | PHOENIX & HAVIX (Original Live Version)
36.9K1 -
15:23
T-SPLY
14 hours agoBUSTED Assistant Principle And Brother Arrested For Wanting To Kill ICE!
34.4K13 -
22:06
Jasmin Laine
14 hours agoCBC STUNNED Into SILENCE After JD Vance’s BRUTAL Message to Canadians
26.7K18 -
2:04:27
TimcastIRL
13 hours agoAntifa CONVICTED Of TERRORISM, Fears Of CIVIL WAR Grow | Timcast IRL
260K101