filmov
tv
Understanding Inheritance in CSS
Показать описание
► Inheritance is the behavior through which some elements can inherit styles that are applied to ancestor elements, rather than directly to themselves.
So if a font is applied to a div element, for example, then that same font is applied to all text inside the div. Including the text enclosed within child elements of that div.
If we were unable to do this in CSS, and property values could not be inherited by descendant elements, then we’d have to laboriously select each of the child elements directly and apply the font to those too.
We should be aware that not all properties will be passed down to be inherited. A perfect example is styles associated with the CSS box model. So borders, margins, and paddings are not inherited by descendants of elements they are applied to.
Another thing we should note is that values that have been inherited have an absence of specificity. Not even a specificity of zero. So are easily overridden.
► Timestamps:
0:00 Start
0:28 Codepen project
0:40 Inheritance example
2:10 Defining Inheritance
2:46 Trees diagram to visualise inheritance
3:35 Styles propagate down the document but not up
4:07 Not all CSS style properties can be inherited
4:40 using advanced selectors to pass non-inherited properties
6:09 Inherited values have an absence of specificity
6:20 Specificity calculator
7:10 The potential problem with using universal selector
8:10 Not elements will accept inherited styles
9:42 Overriding default browser styles
10:16 Styling the form input’s placeholder text
10:27 Summary
12:07 In the next video…
► Get the code:
► Links used in the video:
MDN Cascade & Inheritance:
► Social Media:
► Code & Projects:
So if a font is applied to a div element, for example, then that same font is applied to all text inside the div. Including the text enclosed within child elements of that div.
If we were unable to do this in CSS, and property values could not be inherited by descendant elements, then we’d have to laboriously select each of the child elements directly and apply the font to those too.
We should be aware that not all properties will be passed down to be inherited. A perfect example is styles associated with the CSS box model. So borders, margins, and paddings are not inherited by descendants of elements they are applied to.
Another thing we should note is that values that have been inherited have an absence of specificity. Not even a specificity of zero. So are easily overridden.
► Timestamps:
0:00 Start
0:28 Codepen project
0:40 Inheritance example
2:10 Defining Inheritance
2:46 Trees diagram to visualise inheritance
3:35 Styles propagate down the document but not up
4:07 Not all CSS style properties can be inherited
4:40 using advanced selectors to pass non-inherited properties
6:09 Inherited values have an absence of specificity
6:20 Specificity calculator
7:10 The potential problem with using universal selector
8:10 Not elements will accept inherited styles
9:42 Overriding default browser styles
10:16 Styling the form input’s placeholder text
10:27 Summary
12:07 In the next video…
► Get the code:
► Links used in the video:
MDN Cascade & Inheritance:
► Social Media:
► Code & Projects:
Комментарии