--- id: css-inheritance title: "CSS Inheritance" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["CSS inheritance", "inherited properties", "non-inherited properties", "inherit keyword", "property inheritance"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.87 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["css", "web", "frontend", "w3schools", "inheritance", "cascade"] raw_sources: ["https://www.w3schools.com/css/css_inheritance.asp"] applied_in: [] github_commit: "" --- # [[CSS Inheritance]] ## π― ν μ€ ν΅μ°° (One-line insight) CSS inheritance governs what happens when no value is specified for a property on an element: some properties (typically text-related) inherit their parent's value, others (box-model/layout) do not, and the `inherit` keyword forces inheritance explicitly on either kind. [S1] ## π§ ν΅μ¬ κ°λ (Core concepts) - **What inheritance is** β CSS inheritance is about what happens if no value is specified for a property on an element; values either inherit from parent elements or default to initial values. [S1] - **Inherited properties** β text-related properties like `color`, `font-family`, `font-size`, `line-height`, and `text-align` are typically inherited, ensuring consistent styling throughout a document. [S1] - **Non-inherited properties** β box-model/layout properties like `border`, `background`, `margin`, `padding`, `width`, and `height` typically do not inherit. [S1] - **`inherit` keyword** β used to explicitly specify inheritance; it works on both inherited and non-inherited properties. [S1] ## π§© μΆμΆλ ν¨ν΄ (Extracted patterns) - **Rely on inheritance for typography** β set text properties on a container and let descendants inherit them rather than repeating declarations. [S1] - **Force inheritance with `inherit`** β when a non-inheriting property (like `border`) should match the parent, set it explicitly to `inherit`. [S1] ## π μΈλΆ λ΄μ© (Details) **CSS Inheritance** CSS inheritance is about what happens if no value is specified for a property on an element. The value either inherits from parent elements or defaults to initial values. [S1] **Inherited Properties** Text-related properties such as `color`, `font-family`, `font-size`, `line-height`, and `text-align` are typically inherited so styling stays consistent throughout the document. A `
` element with `color: blue` and `font-size: 20px` passes these values to a nested `` element: [S1]
```css
p {
color: blue;
font-size: 20px;
}
```
```html
This is a paragraph with some important text. ` will not inherit the border unless explicitly stated: [S1]
```css
p {
border: 1px solid red;
}
```
```html
This is a paragraph with some important text. This is a paragraph with some strong text.