CSS (Cascading Style Sheets) controls how HTML elements look on a webpage. It separates content (HTML) from presentation (styling).
selector { property: value; }
CSS selectors target HTML elements to apply styles:
h1 { color: green; }.topic { padding: 20px; }#header { font-size: 24px; }CSS supports multiple ways to specify colors:
color: red; background-color: blue;color: #4CAF50; background-color: #f5f5f5;color: rgb(255, 0, 0);color: rgba(255, 0, 0, 0.5); (with transparency)Control how text appears on the page:
font-family: Arial, sans-serif; - Choose fontsfont-size: 16px; - Text sizefont-weight: bold; - Bold textcolor: #333; - Text colortext-align: center; - Alignmentline-height: 1.8; - Space between lines
Every HTML element is a rectangular box with these parts:
padding: 20px; - Space insideborder: 1px solid #ddd; - Border linemargin: 10px; - Space outside
background-color: #f5f5f5;
border: 1px solid #ddd;border-left: 3px solid #4CAF50;
Control the size of elements:
width: 100px; - Fixed widthmax-width: 1000px; - Maximum widthheight: 50px; - Fixed heightmargin: 0 auto; - Center horizontally
Controls how elements behave in the layout:
display: block; - Takes full width (like <div>, <p>)display: inline; - Flows with text (like <span>, <a>)display: none; - Hides the element completelyCompare this to the Beginner page to see the progression!