Home >Web Front-end >CSS Tutorial >CSS Tutorial: CSS Selector, Attribute, Value_Basic Tutorial

CSS Tutorial: CSS Selector, Attribute, Value_Basic Tutorial

WBOY
WBOYOriginal
2016-05-16 12:05:122170browse

body {
font-size: 0.8em;
color: navy;
}
The above means to set the font-size font size and color font color for the body selector.

So basically, when it works with an HTML page, the text color between the body tags (the content in the entire window) is navy and the font size is 0.8ems.

Length and percentage

There are many attribute values ​​​​in CSS that need to be specified in units, but some basic units are used on some attributes, and it is worth specifying them before.
em For example, font-size:2em gives the calculated size of the font, so 2em is twice the actual font size.
px, for example, font-size:12px is the unit of pixel.
 ptFor example, font-size:12px is the unit of points.
% For example, font-size: 80% is a percentage
Other units include pc (12-point Western type), cm (centimeter), mm (millimetre) and in (inch)

When value When it is zero, no unit is needed. For example: border:0 means no border.

Web pages are not static, absolute media. This means that within the scalable shape, users should be allowed to adjust it the way they like, including font size and screen size.

Because of this, it is recommended to use "em" and "%" in font-size (width and height). In comparison, px cannot change the size in most browsers, so use it sparingly. You can use on the size of the border.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn