How to set CSS attributes to default values for a specific element (or prevent inheritance)

后端 未结 7 1166
旧时难觅i
旧时难觅i 2021-01-04 00:47

Given any HTML element that is a child of another element and is automatically inheriting a series of CSS attributes: how can you set one (or all) of those attributes to the

7条回答
  •  鱼传尺愫
    2021-01-04 00:59

    If you are saying about the browser defaults than look at CSS reset stylesheets, they are all over the web, those stylesheets reset each elements properties to a standardized value.

    Few Examples

    Meyer Web

    HTML5 Doctor (CSS Reset With HTML5 Elements Included)

    If you are saying manual style resets and ignore inheritance, than until now, there's no way to reset the styles completely unless and until you re-declare their values so for example

    div {
       color: red;
       font-family: Arial;
    }
    
    div p {
       /* Here it will inherit the parents child unless and 
          until you re specify properties with different values */
    }
    

提交回复
热议问题