diff --git a/docs/css/basics/cascading-order.mdx b/docs/css/basics/cascading-order.mdx index f488562..eb0706a 100644 --- a/docs/css/basics/cascading-order.mdx +++ b/docs/css/basics/cascading-order.mdx @@ -13,6 +13,9 @@ The browser doesn't guess; it uses a strict set of rules known as the **Cascade* 2. **Specificity:** How detailed is the selector? 3. **Inheritance:** Does the element automatically get its parent's style? + +
+ ## 1. The Cascade: Order and Source The **Cascade** is the primary system for layering styles. It decides the initial winner based on the origin and order of the stylesheet. @@ -70,6 +73,9 @@ Let's compare two conflicting selectors: Never use Inline Styles and try to reserve **ID selectors** (`#`) for JavaScript targeting rather than styling, as their high specificity makes CSS harder to override and maintain. ::: + +
+ ## The Power of `!important` The `!important` keyword is the nuclear option of CSS. When added to a declaration, it instantly makes that style rule **override all other rules**, regardless of specificity. @@ -130,6 +136,9 @@ Properties related to the **Box Model** and **Layout** do **not** inherit: The browser applies the `font-family` to the `

` elements, but since `border` is not inherited, the `

` tags will not have a border unless one is specifically declared for them. + +
+ ## Interactive Cascade Order Demo This interactive example shows how **Specificity** (ID vs. Class) and **Source Order** (last rule wins) determine the final style. diff --git a/docs/css/basics/external.mdx b/docs/css/basics/external.mdx index b80ff36..d7ea382 100644 --- a/docs/css/basics/external.mdx +++ b/docs/css/basics/external.mdx @@ -9,6 +9,9 @@ You've explored **Inline** (least scalable) and **Internal** (single-page only) External stylesheets are CSS rules saved in a **separate file** (usually named `style.css` or similar) and then connected to the HTML document using the `` tag. + +
+ ## How to Implement External Styles This method achieves true **separation of concerns** by keeping your presentation code entirely separate from your structural HTML code. @@ -107,7 +110,10 @@ Now that you know the three ways to add styles, let's briefly look at the order The Cascade is more complex, involving **Specificity** (which we'll cover in a future lesson), but generally, a style defined closer to the HTML element (inline) overrides a style defined further away (external). -## Summary of CSS Methods + +
+ +:::note Summary of CSS Methods | Method | Where is the Style? | Multi-Page Reuse? | Best for? | | :--- | :--- | :--- | :--- | @@ -115,6 +121,8 @@ The Cascade is more complex, involving **Specificity** (which we'll cover in a f | **Internal** | Inside the `