CSS knowledge point font size attribute Font-size

Source: Internet
Author: User

Managing the size of text is important in the field of web design. However, you should not make the paragraph look like a caption by resizing the text, or make the title look like a paragraph. Always use the correct HTML headings, such as use

The Font-size value can be an absolute or relative value.

Absolute:

Sets the text to the specified size

Do not allow users to change the size of text in all browsers (not for usability)

Absolute size is useful when determining the physical size of the output

Relative size:

To set the size relative to the surrounding elements

Allow users to change text size in the browser

Note: If you do not specify a font size, the default size for normal text (such as paragraphs) is 16 pixels (16px=1em).

Use the image to set the font size

By setting the text size in pixels, you can have full control over the text size:

In Firefox, Chrome, and Safari, you can readjust the text size of the above example, but not in Internet Explorer. Although the size of the text can be resized through the browser's zoom tool, this is actually an adjustment to the entire page, not just text.

Use EM to set font size

Many developers use EM units instead of pixels to avoid problems with text that cannot be adjusted in Internet Explorer. It is recommended to use EM size units. 1em equals the current font size. If the font-size of an element is 16 pixels, then for that element, 1em is equal to 16 pixels. When you set the font size, the value of EM changes relative to the font size of the parent element.

The default text size in the browser is 16 pixels. So the default size of 1em is 16 pixels. You can use this formula to convert pixels to em:pixels/16=em(Note: 16 equals the default font size of the parent element, assuming the parent element's font-size is 20px, the formula should be changed to:pixels /20=em)

CSS knowledge point font size attribute Font-size

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.