What Is CSS?
Cascading Style Sheets (full name in English: Cascading Style Sheets) is a computer language used to express file styles such as HTML (an application of the standard universal markup language) or XML (a subset of the standard universal markup language). CSS can not only decorate web pages statically, but also can dynamically format elements of web pages in conjunction with various scripting languages. [1]
- Cascading Style Sheets (English full name: Cascading Style Sheets) is a kind of
- Programming Tools
- Notepad: Use the notepad that comes with Windows to edit web pages. Just save the document with the .html extension. [6]
- CSS provides a style description for the HTML markup language, which defines how elements are displayed. CSS is a breakthrough in the field of web design. Use it to modify a small style to update all page elements related to it.
- In general, CSS has the following characteristics:
- Rich style definition
- CSS provides a rich document style appearance, and the ability to set text and background properties; allows the creation of borders for any element, the distance between the element border and other elements, and the distance between the element border and the element content; allows the text Capitalization, modification, and other page effects.
- Easy to use and modify
- CSS can define the style in the style attribute of the HTML element, it can also be defined in the header part of the HTML document, or you can declare the style in a special CSS file for HTML page reference. In short, CSS style sheets can store all style declarations for unified management.
- In addition, you can classify elements of the same style and use the same style to define, you can also apply a style to all HTML tags with the same name, or you can specify a CSS style to a page element. If you want to modify the style, we just need to find the corresponding style declaration in the style list to modify it.
- Multi-page application
- CSS style sheets can be stored separately in a CSS file, so we can use the same CSS style sheet in multiple pages. CSS style sheets do not theoretically belong to any page file, and can be referenced in any page file. In this way, the style of multiple pages can be unified.
- Cascade
- To put it simply, cascading is to set the same style multiple times for an element, which will use the last property value set. For example, the same set of CSS style sheets is used for multiple pages in a site, and some elements in some pages want to use other styles. You can define a style sheet for these styles and apply it to the page. These later defined styles will overwrite the previous style settings, and you will see the last style effect in the browser.
- Page compression
- In websites that use HTML to define page effects, a large number or repeated forms and font elements are often required to form text specifications of various specifications. The consequence of this is that a large number of HTML tags will be generated, which will increase the size of the page file. Putting the style declaration into the CSS style sheet alone can greatly reduce the page size, so that the time used when loading the page will also be greatly reduced. In addition, the reuse of CSS style sheets has greatly reduced the size of the page and reduced the download time. [8]
- CSS is a language that defines style structures such as fonts, colors, positions, etc., and is used to describe the formatting and reality of information on web pages. CSS styles can be stored directly in HTML pages or in separate style sheet files. Either way, a style sheet contains rules for applying styles to elements of a specified type. When used externally, the style sheet rules are placed in an external style sheet document with the file extension _css.
- Style rules are formatting directives that can be applied to elements in a web page, such as text paragraphs or links. A style rule consists of one or more style attributes and their values. The internal style sheet is placed directly on the web page, the external style sheet is stored in a separate document, and the web page links the external style sheet through a special label.
- "Cascading" in the name CSS indicates how style sheet rules are applied to HTML document elements. Specifically, the styles in the CSS style sheet form a hierarchy, and more specific styles cover general styles. The priority of style rules is determined by CSS according to this hierarchy, so as to achieve the cascading effect. [9]
- In the CSS 2.1 specification, identifiers (including element names, classes, and IDs in selectors) can only contain characters from A to Z, a to z, and 0 to 9, plus hyphens "-" and underscores "_" . Identifiers cannot begin with a digit, and hyphens and underscores are not allowed. Only attributes, attribute values, units, pseudo-classes, pseudo-elements, and "@" rules can begin with a hyphen "-". Also, other element names, classes, and ID identifiers are not allowed to begin with a hyphen.
- CSS identifiers also need to use the backslash "\" to escape special characters, these escape characters follow the IS010646 specification. There are two ways to avoid special characters. The first method is to add special backslashes before special characters. For example, "AT & T" becomes "AT \ & T". The hexadecimal value, such as Unicode or IS010646, is used to escape special characters. For example, "AT & T" becomes "AT \ 26T". [12]
- website
- Add a hyperlink to the HTML file to introduce external CSS documents. This method is most convenient to manage the webpage style of the entire website. It separates the text content of the webpage from the layout design. As long as the style of the web page is defined in a CSS document (with the extension of CSS ), and then a hyperlink is added to the document to connect to the document, the web page will be displayed according to the style defined in the CSS document. [13]
- Cascading Style Sheets ( CSS ) help achieve responsible web design. CSS has a huge impact on developers building Web sites, and this impact can be endless. There are many advantages to removing most or even all of the presentation information of a web page from ( X ) HTML files and keeping them in a style sheet, such as reducing file size, saving network bandwidth, and easy maintenance. In addition, the performance information of the site is separated from the core content, so that the site designer can make various modifications to the entire site in a short period of time. [14]
- CSS simplifies the formatting code of web pages, external style sheets are also stored in the cache by the browser, speeding up download and display, and reducing the amount of code that needs to be uploaded ( because repeated formatting will be saved only once ). As long as you modify the CSs style sheet file that holds the website format, you can change the style and characteristics of the entire site, which is especially useful when modifying a site with a large number of pages. This avoids the modification of individual web pages and greatly reduces the workload. [15]