Another concept that is important to understand is that some CSS properties can be inherited. This means that setting that property on an element will affect all the child elements within in as well. Whether or not a property can be inherited or not really depends on the nature of the property.
For example, it makes sense for properties like color, which affect the colour of the text within an element or font-family, which determines the font face used by the text within an element, to be inherited. It would be quite annoying to have to explicitly declare the font for every element, especially in the document with lots of content.
On the other hand, properties like width or any of the sizing-related properties are not inherited. If they were, it would also make CSS quite annoying to use. Even though they are a lot of CSS properties out there, you don’t have to memorise how all of them behave. As you continue your web development journey, there will be a number of CSS properties that become second nature to you.
Welcome! Unfortunately, you don’t have access to this lesson. To get access, please purchase the course or enroll in Magical Dev School.
Unlock this lesson