HTML+CSS Easy to Get Started with Inheritance

css is the abbreviation of cascading style sheets, and its specifications represent a unique development stage in the history of the Internet. Nowadays, for friends who are engaged in web page production, it is rare that they have not heard of css, because we often need to use it in the process of making web pages.
css allows us to set a richer and easier-to-modify appearance for documents, which can reduce the work burden of web designers. Here we mainly want to have an in-depth discussion with our friends on the inheritance and particularity of CSS

1. Inheritance
One of the main features of CSS is inheritance, which depends on the ancestor-descendant relationship. of. Inheritance is a mechanism that allows styles to be applied not only to a specific element, but also to its descendants

Inheritance is a rule that allows styles to be applied not only to a specific html tag element , and applied to its descendants. For example, the following code: If a certain color is applied to the p tag, this color setting is not only applied to the p tag, but also to all sub-element texts in the p tag

p{color:red}

When we have a p tag, all elements within the p tag will use the style of the p tag

    继承  

css继承性 重要性

2. Limitations of css inheritance

In css, inheritance is a very natural behavior , we don't even need to consider whether we can do this, but inheritance has its limitations.

First of all, some properties cannot be inherited. There's no reason for this, just because that's how it's set up. For example: the border attribute. As we all know, the border attribute is used to set the border of an element, and it has no inheritance. Most border properties, such as padding, margin, background and border properties, cannot be inherited.

3. Errors that are easy to cause in inheritance

Sometimes inheritance will also bring some errors

4. Mixed application of multiple styles

Since there are Without inheritance, some readers may be confused about the application in style sheets. What will happen if multiple style sheets are applied to an object at the same time?

5. The priority issue of css inheritance

Use css styles close to the document

Continuing Learning
||
继承

css继承性 重要性

submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!