CSS style specifications 1. Class Selector 2. Tag selector 3. ID selector 4. CSS style child selector Class Selectors 1. The fixed structure that must be memorized becomes a CSS style tag. All styles can be written in CSS style tags <style type="text/css"> </style> 2. type="text/css" means declaring this tag as a CSS style type type: type means 3. Class selector syntax format. Class name (dot plus class name) Write location: Call the method in the CSS style tag and write class=class name inside the HTML tag 4. Naming conventions It is recommended to use pure letters or letters followed by numbers. Do not start with numbers. Although other names can be used, please ask how to use them. 5. Why should we extract the inline CSS into the CSS tag? Advantage 1: Keep HTML hierarchy clear and easy to detect errors Advantage 2: CSS styles can be reused XML/HTML CodeCopy content to clipboard
ID Selector 1. The syntax format of ID selector is #ID name Write location: Call the method in the CSS style tag and write id="ID name" inside the HTML tag The same reason as the class name in the previous section 3. Why extract inline CSS into CSS tags Advantage 1: Keep HTML levels clear and easy to detect errors Advantage 2: Distinguish priorities. If you need to reuse, please choose a class selector 4. ID does not allow repeated calls. ID is like an ID card number. Each one is different. XML/HTML CodeCopy content to clipboard
Tag name selector When multiple tags use the same attribute, they can be written as a selector. All the following tags share this attribute XML/HTML CodeCopy content to clipboard
CSS style child selector XML/HTML CodeCopy content to clipboard
2. Style Priority 1. CSS execution order. Under the same priority, if the next line of CSS conflicts with the previous line of CSS, the next line will be the standard In case of different priorities, the higher priority overrides the lower priority. 2. Selector priority order First place: Inline style 1000; 3. Things to note: When the CSS you wrote doesn't work, first check if the code is wrong and then check if the priority is wrong. XML/HTML CodeCopy content to clipboard
The above is all the content of the must-read article on HTML (css style specifications) brought to you by the editor. I hope you will support 123WORDPRESS.COM~ Original address: http://www.cnblogs.com/pythonxiaohu/archive/2016/06/25/5616511.html |
<<: 5 tips for writing CSS to make your style more standardized
>>: MySQL tutorial DML data manipulation language example detailed explanation
Installation Environment Description •System vers...
As shown in the following figure: When we use vir...
View historical commands and execute specified co...
When the database concurrently adds, deletes, and...
Non-orthogonal margins When margin is used, it wi...
Table of contents Where is the source code of the...
Table of contents 1. Uninstall the original drive...
When you write buttons (input, button), you will f...
Table of contents 1. Object properties 1.1 Attrib...
Recently, the project uses kubernetes (hereinafte...
Table of contents Preface Motivation for Fragment...
When OP opens a web page with the current firmwar...
By applying it, some public areas of the website c...
Preface In JavaScript, this is the function calli...
Due to the default bridge network, the IP address...