Document directory
Basic knowledge required
Before continuing to learn, you need to have a basic understanding of the following knowledge:
If you want to learn about these projects, visit the relevant tutorials on the homepage.
-
CSS Overview
-
- CSS refers to a Cascading Style Sheet.
- CSS is a standard layout language used to control the size, color, and layout of elements.
- CSS is very precise, powerful, and easy to write.
- CSS was invented by W3C to replace table-based la S, frameworks, and other non-standard representations.
- A style defines how to display HTML elements. A style is usually stored in a style sheet, and an external style sheet is stored in a CSS file.
- External style sheet can greatly improve your work efficiency and greatly save the server bandwidth.
- The combination of pure CSS layout and XHTML can separate the presentation and structure, make the site easier to maintain, and make it easier to use.
Style solves a common problem
HTML tags are originally designed to define document content. By using tags such as
Because the two major browsers (Netscape and Internet Explorer) constantly add new HTML tags and attributes (such as font tags and color attributes) to the HTML specification, therefore, it is increasingly difficult to create sites whose content is clearly independent from the document presentation layer.
To solve this problem, the W3C, a non-profit standardization alliance, shouldered the mission of HTML standardization and created styles outside HTML 4.0 ).
All mainstream browsers support Cascading Style Sheets.
Style Sheets greatly improve work efficiency
A style sheet defines how HTML elements are displayed. For example, the style labels and colors in HTML 3.2are usually stored in external. CSS files. By editing only a simple CSS document, the external style sheet enables you to change the appearance of all the page la s on the site at the same time.
As multiple page styles and la s can be controlled at the same time, CSS can be a breakthrough in the web design field. As a website developer, you can define a style for each HTML element and apply it to any number of pages you want. To perform global transformation, you only need to change the style, and all elements in the website will be automatically upgraded.
Multiple styles are stacked into one
The style sheet allows the style information to be specified in multiple ways. Styles can be specified in a single HTML element, in the header element of an HTML page, or in an external CSS file. Even multiple external style sheets can be referenced within a single HTML document.
Cascade order
Which style will be used when the same HTML element is defined by more than one style?
Generally, all styles are stacked in a new virtual style table according to the following rules, where number 4 has the highest priority.
- Browser default settings
- External style sheet
- Internal style sheet (inside the
- Inline style (inside the HTML element)
Therefore, inline styles (inside an HTML element) have the highest priority, which means they take precedence over the following style Declaration: