CSS Basics – Inheritance (Beginner Level) 2022

CSS styles can be passed down to “children”, that is elements that are contained within an element.

For example, below, <body> has the children of “heading” or “H1” and “paragraph” or “p”.


If we add a style to the body, and there are not specific styles added to the H1 or the <p> elements, they will “inherit” the style from <body>

 body {
 color: red;

If the above code is added our webpage (or in a linked-to CSS sheet), and there is no specific styles given for the heading or paragraph, they will both be red.



Screenshot from Udemy – https://www.udemy.com/course/css-bootcamp-master-in-css-including-css-grid-flexbox/learn/lecture/10708474#overview

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s