INHERITANCE IN CSS

Hank Greenberg

Total Post:12

Points:84
Posted by  Hank Greenberg
 946  View(s)
Ratings:
Rate this:
Hi Developers,

What is meaning of inheritance in CSS terminology? Can you provide any example for better understanding!

Your help is greatly appreciated.
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: Inheritance in CSS


    Some styles, like font family, text-alignment etc., are automatically inherited by child elements from their parent element (i.e. by an element contained inside another one).

    Others are not automatically inherited.

    Example

    <div style=”font-family:serif; border:1px solid red; padding:10px;”>

    This text will be in a serif font.
     <p>
     This text is also in a serif font, because font is inherited by default.
     But the border and padding properties are not inherited from the parent div.
     </p>

    </div>

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!