Some descriptions of font units in HTML

Source: Internet
Author: User

HTML pages, commonly used are px, PT,%, EM, REM

The problem we encountered before using EM, percent, was calculation, and when the nesting level was too long it would be very difficult to control, and the PX would be fixed dead,

Now we don't have to worry about this problem with REM, because REM's Reference object is only the root node. We simply set the size of the root node, and all child nodes can be designed simply by referencing it.

The following is a comparison of PX, EM, percent, and pt.

This refers to a network above the control picture, convenient reference

According to the above chart (the red part is the default, of course, different browser render default value is not the same, the specific needs of you to test) can be seen,

We just set the HTML root element font size to 75%, the corresponding PX value is 12, so we can easily set the width of the page and font size,

Of course the unit is REM, so that the reference object will always be HTML instead of the parent element, when the need to change, just change the size of the HTML other elements will change accordingly.

Some descriptions of font units in HTML

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.