Intro to Cascading Style Sheets (CSS)
Master the fundamentals of styling web content
Core CSS Concepts
Style Tag
Contains CSS rules within the HTML head section. Acts as the container for all internal stylesheet definitions.
Tag Selectors
Target all instances of specific HTML elements. Provide default appearance settings for consistent styling.
CSS Properties
Define visual characteristics like font-family, font-size, color, and line-height for enhanced typography control.
CSS Implementation Process
Add Style Tags
Insert style tags in the HTML head section to create a container for CSS rules
Define Selectors
Create tag selectors to target specific HTML elements like h1, h2, and p tags
Apply Properties
Set font-family, font-size, color, and line-height values for each selector
Test and Refine
Save the file and reload in browser to see styling changes applied
Preview the file in a browser to establish your baseline. In Visual Studio Code with the Live Preview extension (or similar), use Option–B (Mac) or ALT–B (Windows) to open your HTML document in your default browser. This keyboard shortcut streamlines your development workflow by eliminating the need to manually navigate to and open files.
Examine the unstyled structure: notice the main heading (h1), three images, and three news stories. Each story contains a subheading (h2) and multiple paragraphs of text. This represents typical browser default styling—functional but visually uninspiring.
The font-family property creates a fallback system. If the first font is unavailable on the user's computer, the browser automatically tries the next font in the list.
Return to index.html in your code editor to continue building your stylesheet.
Below your existing h1 rule, add styling for subheadings by creating an h2 rule. Add only the bold code shown below:
h1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 35px;
color: #006b3a;
}
h2 {
font-family: Arial, Helvetica, sans-serif;
font-size: 24px;
color: #8f6800;
}
</style>Below your h2 rule, add comprehensive paragraph styling (add only the bold code):
h2 {
font-family: Arial, Helvetica, sans-serif;
font-size: 24px;
color: #8f6800;
}
p {
font-family: Verdana, sans-serif;
font-size: 14px;
line-height: 25px;
}
</style>
The line-height property controls vertical spacing between lines of text—what print designers call "leading." This property defines the total height allocated to each line of text, with characters vertically centered within that space. Increasing line-height adds breathing room above and below text, dramatically improving readability, especially for longer content blocks. The difference between cramped text (line-height: 1.0) and well-spaced text (like our 25px setting) can mean the difference between content that users scan and content they actually read.
Return to your browser and refresh the page to see the complete transformation. The combination of thoughtful font choices, appropriate sizing, and optimized line spacing has converted your basic HTML into professionally styled content that's both visually appealing and highly readable.
Hexadecimal Color System
RGB Structure
Six-digit hex values represent Red, Green, Blue components. First two digits control red, middle two green, last two blue intensity.
Syntax Requirements
Hex values must start with a hash symbol. Letters can be uppercase or lowercase without affecting the color output.
Example Color Values Used
Key Takeaways
