1, selector element, i.e. E {...}, E represents a valid HTML element; * can be used to represent any of elements to a document;
<style type="text/css"> body { margin: 100px; } </style>
2, attribute selector, are summarized as follows:
- E [attr] {...}: Specifies the CSS style E is for all elements with attributes attr;
<!DOCTYPE html> <html lang="en"> <head> <style type="text/css"> div[align] { width:200px; height:100px; border:1px solid red; } </style> </head> <body> <div align="center">我具有align属性</div> <dvi > I do not align attribute </ dvi > </ body > </ HTML >
- E [attr = value] {...}: Specifies the CSS style E is for all elements with attributes attr, and the value is value;
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> div[align="center"] { width: 200px; height: 100px; border: 2px solid blue; } </style> </head> <body > < div align = left = "Center" > I have align = "center" attribute </ div > < div align = left = "left" > I have align = "left" attribute </ div > </ body > </ HTML >
- E [attr ~ = value] {...}: Specifies having all the CSS style attributes attr, and the plurality of attribute values, separated by a space, for a value of the function value of the element E;