css is the abbreviation of English Cascading Style Sheets, which is called cascading style sheets and is used to beautify the page. There are three ways of existence:
element inline, page embedding and external introduction. Compare the advantages and disadvantages of the three methods.
Syntax: style='key1:value;key2:value2;'
Use style='xx:xxx;'
In the tag, embed in the page: < ;style type='text/css'> block
Introducing external css files
<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/css"; charset="UTF-8"> <title>页面一</title> <link rel="stylesheet" href="commom.css" /> <style> .logo{ background-color:red; } </style> </head> <body> <div class='logo'>123456</div> <div class='logo'>aaa</div> </body> </html>
##3. Introduce external css files
If there are multiple html files that need to reference custom css styles, then according to the second method, you need to define a style in each html file. In order to solve this problem, you can define a file and write custom style, and then call this style from the file. How to write
style:
<style> .logo{ background-color:red; } #logo{ background-color:red; } a,div{ color:red; } a div{ color:red } input[type='text']{ color:blue } .logo a,.logo p{ font-size:56px; } </style>
1. When the class selector
.logo indicates class='logo', quote the style
2. ID selector
#When logo indicates id='logo', reference this style
3. Combination selector The selector
a, div means that all a tags and div tags refer to this style
4. The associated selector
a div Represents a hierarchical relationship, that is, all div tags below the a tag apply this style.
5. Attribute selector
input[type='text'], attribute label, indicating that all labels of type 'text' refer to this Style
6, .logo a, .logo p means when class='logo', all the following a tags and when class='logo', all the following p tag, refer to the style
For more CSS style selector related articles, please pay attention to the PHP Chinese website!