Basic syntax and derived selectors for CSS

1. Basic grammar of css
1) Grammar:
selector (attribute selector) {
    property: value
}
Example:
     h1 {
          color:red;font-size:50px;
       }

If the attribute is more than one, separate the attributes with commas
If the value is more than one word, the value should be enclosed in quotation marks
2) Selector group
h1, h2, h3, a{
    color:red
}
Set the same style for multiple tags
3 ) Inheriting
body{
   color:biue
}
All tags without their own styles will update the style of the body, and tags with their own styles will update their own styles
2. Derived selectors define styles
according to the context of the element in its position
Two tags Separate with spaces
Example
     li strong{
        color:red
    }
     strong{
         color:blue
        }

The strong tag in the li tag inherits his own style, and other strong tags inherit the style of strong
3. Class selector: a selector that specifies styles independently of html elements.
Example : .woning{
     color:red
}
has a prefix of '. ' is the class selector
4.ID selector:
Example:
#car{
   color:blue
}
with the prefix '#' is the ID selector

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326724519&siteId=291194637