Css|select
HTML has tags, CSS has selectors. Selectors are named for styles inside and outside styles.
Each selector has attributes in {}
it, such as a simple dot image color
, font-weight
or background-color
.
The value is followed by a colon (not equal sign) and the semicolon separates the attribute.
body {font-size: 0.8em;color: navy;}
The above meaning is to body
set the font-size
font size and for the selector color字体颜色
.
So basically, when it works with HTML pages, the body
text color between the tags (the entire window content) is navy the font size is 0.8ems.
length and percentage
CSS has many attribute values to specify units, but some basic units are used on some properties, before this is worth the attribute under them.
em , for example font-size:2em
, gives the size of the font, so 2em is twice times the size of the actual font.
px , for example, font-size:12px
is a unit of pixel pixels.
PT , for example, font-size:12px
is a unit of points pounds.
% , such as font-size:80%
percent
Other units include PCs(12-point Western type),cm(cm),mm(mm) and in (inches)
When the value is zero, the unit is not needed, for example: border:0
there is no border.
Web pages are not static, absolute media. This means that internal energy is scaled and distorted, and users should be allowed to adjust their preferred ways, including font size and screen size.
Because of this, it is recommended to use "em" and "%" on the font-size (width and height), compared to the PX can not be in most browsers to change the size, so use less, you can use in the size of the border.