Basic CSS syntax
A stacked style sheet is a computer language used to represent file styles such as HTML (an application of the standard universal Markup Language) or XML (a subset of the standard universal Markup Language. CSS is currently in the latest version of CSS3. It is a style design language that truly achieves the separation of webpage performance and content. Compared with traditional HTML, CSS can precisely control the position and layout of objects in webpages in pixels, and supports almost all font size styles, with the ability to edit webpage objects and model styles, and preliminary interactive design, it is currently the best presentation design language based on text display. CSS can simplify or optimize the writing Based on the comprehension ability of different users. It is easy to understand for various groups of users. 2. The basic syntax CSS rule consists of two main parts: Selector and one or more declarations. 1 selector {declaration1; declaration2;... declarationN} Each declaration consists of an attribute and a value. 1 selector {property: value} in the following example, h1 is the selector, color and font-size are attributes, and red and 14px are values. 1h1 {color: red; font-size: 14px;} 3. selector type ). tag selector: a selector is usually an HTML Tag, such as p, h1, em, a, or even html.
html {color:black;}h1 {color:blue;}h2 {color:silver;}
B). class selector: A class selector usually starts with a. Sign and is referenced in an HTML file through the class attribute.
.important {color:red;}
C). ID selector: generally starts with # And is referenced by the id attribute in HTML files. Unlike the class selector, the ID selector can only be used once in the document. # MostImportant {color: red; background: yellow;} <p style="color: sienna; margin-left: 20px">This is a paragraph</p>
B). Internal style sheet: an internal style sheet should be used when a single document requires a special style. You can use the <style> label to define an internal style sheet in the Document Header, as shown in the following figure:
C). External style sheet: an external style sheet is ideal when a style needs to be applied to many pages. When using an external style sheet, you can change the appearance of the entire site by changing a file. Use the <link> label to link to the style sheet on each page. <Link> tag in (document) header: