Inheritance
๐ SitePoint โฉ CSS Inheritance: An Introduction
inherit
inheritance flows down the DOM tree.
use
inheritto make inheritance take precedence over the cascaded value.use
inheritto force inheritance of a property not normally inherited, such as border or padding. ๐See: border-box fix
intial
Every CSS property has an initial (default) value. If you assign
initialto that property, then it resets to its default value.remove a border:
border: initialrestore default width:
width: initial
property
default value
note
width
auto
display
inline
examples
/* global link color */
a:link { color: blue; }
/* parent */
.footer {
color: #666;
background-color: #ccc;
padding: 15px 0;
text-align: center;
font-size: 14px;
}
/* child */
.footer a {
color: inherit; /* inherit from parent: #666 */
text-decoration: underline;
}.footer a {
color: initial; /* = `color: black` */
text-decoration: underline;
}inherited properties
font-family
font-size
font-style
font-variant
font-weight
font
letter-spacing
line-height
text-align
text-indent
text-transform
white-space
word-spacinglist-style-image
list-style-position
list-style-type
list-style/* control border behavior of tables */
border-collapse
border-spacingazimuth
caption-side
color
cursor
direction
elevation
empty-cells
orphans
pitch-range
pitch
quotes
richness
speak-header
speak-numeral
speak-punctuation
speak
speech-rate
stress
visibility
voice-family
volume
widowsreferences
Last updated
Was this helpful?