CSS Tutorial Lesson 9: Inheritance

To save time from having to design CSS styles for each and every element, we can use the inherit property to apply the styles from the parent element to the child elements. Child elements are elements contained inside a element which is called the parent elemnent.
For example,
I am the child element  of div and I am the child element of p and  also a child element of div
.
In the above example, p is the child element of div and b is the child element of both p and div.
Let’s examine the following example:

Example 9.1




Inheritancein CSS





We have learned about child and descendent selectors in previous lesson.


In this lesson, we shall learn about
inheritance in CSS



The Output

We have learned about child and descendent selectors in previous lesson.
In this lesson, we shall learn about
inheritance in CSS
* Notice that the first p element inherits the css styles of the div element and the second p element inherits css styles from the body element.

Post a Comment

0 Comments