**CSS(Cascading Style Sheets)**

Is what?

CSS, commonly referred to as CSS style sheets or cascading style sheets (cascading style sheets), is mainly used to set the text content (font, size, alignment, etc.), image shape (width and height, border style, margins, etc.), and layout of the layout of the HTML page.

Based on HTML, CSS provides rich functions such as font, color, background control and overall layout, and can be set to different styles for different browsers.

CSS style rules When using HTML, you need to follow certain specifications. CSS is the same, in order to skillfully use CSS to modify the web page, first need to understand the CSS style rules, the specific format is as follows:




In the style rule above:

1. The selector is used to specify the CSS style applied to the HTML object. The curly braces are the specific style applied to the object.

2. Attributes and attribute values are displayed in key-value pairs.

3. Properties are style properties set for a specified object, such as font size, text color, etc.

4. Attribute and attribute value are connected by colons (:).

5. Use English “; “between multiple” key-value pairs “. Make a distinction. Can use paragraph and table alignment demonstration.

CSS Font Style properties FONT-size: font size

The font-size property is used to set the size, and the value can be in either relative or absolute units of length. Among them, relative length unit is more commonly used, pixel unit px is recommended, and absolute length unit is rarely used.

Font-family: font The font-family property is used to set the font.

Font-family: 宋体; mso-ascii-font-family: ‘Microsoft yahei’; mso-ascii-font-family: ‘Microsoft yahei’; } You can specify multiple fonts at the same time, separated by commas, to indicate that if the browser does not support the first font, the next font will be tried until a suitable font is found.

1. 14px+ is now commonly used on web pages.

2. Use even numbers. Older browsers such as IE6 support odd numbers can be buggy.

3. Use commas (,) to separate fonts.

4. Chinese fonts need to be quoted in English, but English fonts generally do not need to be quoted. If you need to set an English font, the English font name must precede the Chinese font name.

5. If the font name contains Spaces, #, and $, use single or double quotation marks (“), for example, font-family: “Times New Roman”. .

6. Use the default font to ensure that it can be correctly displayed in any user’s browser.

It is possible to set the font name in CSS and write it in Chinese. However, if the file encoding (GB2312, UTF-8, etc.) does not match, garbled characters will be generated. Xp does not support Chinese like Microsoft Yahei.

Plan 1: You can use English instead. Font-family :”Microsoft Yahei”;

Scheme 2: Use Unicode encoding directly in CSS to write font names to avoid these errors. Using Unicode to write Chinese font names, browsers can correctly parse them.

  • Font-family: “\5FAE\8F6F\96C5\9ED1”; font-family: “\5FAE\8F6F\96C5\9ED1”;
  • You can test what font you belong to by using escape().

In order to accommodate font installation problems on different computers, we try to use only Song Style and Microsoft Yahei Chinese fonts

In addition to using b and strong tags, font thickening can be done using CSS, but CSS has no semantics.

The font-weight attribute defines the font size. The available attribute values are Normal, bold, bolder, lighter, and 100 to 900 (integer multiple of 100). Tip: The numbers 400 are equivalent to normal and 700 is equivalent to bold. But we prefer to use numbers.

Font slant can be implemented using CSS in addition to the I and EM tags, but CSS has no semantics.

The font-style attribute defines the font style, such as italic, slanted, or normal. The available values are as follows: Normal: The default value. The browser displays the standard font style. Italic: The browser displays italic font styles. Oblique: Browsers display slanted font styles.

Tip: We rarely italicize text, preferring instead to change the italic tag (em, I) to normal.

The font property is used to set the font style comprehensively. The basic syntax format is as follows: selector {font: font-style font-weight font-size/line-height font-family; } When using the font attribute, the characters must be written in the sequence specified in the preceding syntax format. The characters must be separated by Spaces.

Note: The properties that do not need to be set can be omitted (take the default values), but the font-size and font-family properties must be kept, otherwise the font property will not work.