CSS basics 3-use CSS to format the font of Element Content

Source: Internet
Author: User

CSS basics 3-use CSS to format the font of Element Content

1. CSS attribute Unit:

(1) length unit: Includes absolute length units and relative length units

The absolute length units include cm, mm, in, pt, and pc. The absolute length unit is best used to print the output device. When it is only displayed as a frequency screen, the absolute length value is meaningless.

The relative length units include px, em, and ex. The relative length refers to the scaling of the element size relative to the system default value of the browser. Em is the font size relative to the text M in the current object. Ex is the font size relative to the current object's Chinese Character X. If the font size of the row text is not set manually, the default font size is relative to that of the browser.

Px, em, percentage conversion: 16px = 1em = 100% 1px = 0.0625em = 6.25%

(2) color unit:

Percent representation, such as color: rgb (50%, % );

Set it with an integer between 0 and 127, such as color: rgb (, 0 );

Use a hexadecimal array to define the color, such as color: # e1e1e1;

Use a simplified hexadecimal number to define the color, such as color: # fa1; equivalent to # ffaa11;

Use English colors, such as black and white.

(3) URL Unit: The format is followed by a bracket after "url", which contains the url address.

2. Set the font of the element content

(1) settingsFont Name:Font-family

You can set fonts such as and Arial. Secure fonts (such as arial, verdana, and) cannot be used. Multiple fonts can be created at the same time and separated by commas (,). The advantage of this setting is that if the first Font does not exist in the computer, the browser can use the specified font later.

(2)Font skew: Font-style

Attribute values include normal, italic, and oblique.

(3)Font variations: Font-variant

The attribute values include normal/small-caps. The upper-case letters in the font of the elements using the small-caps attribute seem to be smaller than normal upper-case letters.

(4)Word weight: Font-weight

Attribute values include normal/bold/bolder/lighter/100/200/300/400/500/600/700/800/900. 400 is equivalent to normal, 700 is equivalent to bold, and 900 is the heaviest font. Bolder or lighter indicates that the font's word weight is higher or lower than that of the parent element.

(5)Font Size: Font-size

Attribute values include: <绝对大小> (Such as 12pt )/ <相对大小> (Such as 1.5em )/ <百分比> (E.g. 150%)

(6)Abbreviation of font attribute: Font. The attribute order is {font-style, font-variant, font-weight, font-size, and font-family} separated by spaces. For example, p {font: normal small-caps bold 120% ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.