Allows users to control the font size of webpages by themselves.

Source: Internet
Author: User
Css writing method that allows users to control the font size of web pages. Currently, most websites in China use CSS to set the font size to 12px. Although pixels are relative size units, they are only relative to the screen resolution, when the screen resolution is certain, if you feel that the word is too small and reading is difficult, you can't do anything in a non-standard browser. Therefore, if you change the unit to em, you can use CTRL + to scroll up the word, or use View> text size on the menu to change the word size.

How to Set

1. in the body tag, set the font size to 62.5%. If no CSS is set in the body, the default size of the browser is 16px with 62.5%, the font size is 16px * 62.5% = 10px. You can use em to set the size easily. For example, if you need 12px, you only need to set 1.2em.

Body {
Font-size: 62.5%;
}

H1 {
Fong-size: 1.4em;/* the size of h1 is equal to 14px */
}
2. If the font size in the body is set to 75%, the font size is 16px * 75% = 12px, and 1em is equivalent to 12px.

Body {
Font-size: 75%;
}

H1 {
Fong-size: 1.5em;/* the size of h1 is equivalent to 18px */
}

The first method is better.

For an English website, you can also set it to small, x-small ......

Of course, the page design requirements will be higher.
Related Article

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.