Inheritance in CSS

Posted by  Hank Greenberg
 1491  View(s)
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. 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.


    <div style=”font-family:serif; border:1px solid red; padding:10px;”>
    This text will be in a serif font.
     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.

      Modified On Mar-30-2018 03:57:53 AM