First: 4 ways to introduce CSS There are four ways to introduce CSS: inline style, embedded style, link style, and import style. 1. Inline styles The most direct and simplest one is to use style="" directly on the HTML tag, for example:
Disadvantages: HTML pages are not pure, the file size is large, it is not conducive to spider crawling, and the subsequent maintenance is inconvenient. 2. Inline styles Inline style means writing CSS code between <style type="text/css"> body,div,a,img,p{margin:0; padding:0;} </style> Advantages and disadvantages: The page uses public CSS code, which must be defined for each page. If a website has many pages, each file will become larger and difficult to maintain later. If there are few files and not much CSS code, this style is still very good. 3. Link Style The link style is the most frequently used and practical style. You only need to add
Advantages and disadvantages: It realizes the complete separation of page framework code and presentation CSS code, making pre-production and post-maintenance very convenient 4. Import style (not recommended) Importing styles is similar to linking styles. The @import style is used to import CSS style sheets. When HTML is initialized, it will be imported into the HTML or CSS file and become part of the file, similar to the second embedded style. @import is used in HTML as follows: <style type="text/css"> @import url(style.css); </style> @import is used in CSS as follows:
Second: The priority of four CSS introduction methods 1. Proximity principle 2. In theory: Inline > Embed > Link > Import 3. In fact: embedding, linking, and importing are in the same file header, whichever is closer to the corresponding code has a higher priority Experience:
Summarize This concludes this article on the four import methods and priorities in CSS. For more information on the priority of CSS import methods, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: The process of building and configuring the Git environment in Docker
>>: Vue implements mobile phone verification code login
.NET SDK Download Link https://dotnet.microsoft.c...
After docker run, the status is always Exited Sol...
Table of contents 1. Component Organization 2. Co...
What is a transaction? A transaction is a logical...
Unicode is a character encoding scheme developed ...
An at-rule is a declaration that provides instruc...
Table of contents 1. Event Flow 1. Concept 2. DOM...
This is my first blog post. Due to time constrain...
During development, a good user interface will al...
Basic knowledge of responsive layout development ...
Preface I recently used :first-child in a project...
Introduction to Docker Docker is an open source c...
For more exciting content, please visit https://g...
Environment Introduction Operating system: centos...
Table of contents Preface The role of deconstruct...