CSS (Cascading Style Sheets) is the language we use to style the visual presentation of web pages. It separates design from structure, making websites beautiful and maintainable.
1The Architecture of Style
A CSS rule is a declaration of intent.
- →The Selector: Tells the browser WHICH element to look for (e.g.,
h1,.button,#logo). - →The Declaration Block: Wrapped in curly braces
{ }, this contains one or more property/value pairs. - →Properties: Predefined keywords like
color,margin, orfont-size. - →Values: The settings you apply, like
32pxor#FF0099. Every declaration MUST end with a semicolon (;).
2Cascade Control
Why the name 'Cascading'? Because rules flow from top to bottom.
- →External Link: The gold standard. Keeps styles in a separate
.cssfile for site-wide consistency. - →Internal Style: Placed in the
<style>tag within the HTML<head>. Good for single-page overrides. - →Specificity: This is the 'weight' of a selector. An ID is worth more than a Class, which is worth more than a Tag. If specificity is equal, the last rule written in the code is the one the browser applies.
