rem px PT EM

Source: Internet
Author: User
Tags manual relative

px (Pixe, pixel L): is a virtual length unit, is the digital image length unit of the computer system, if PX to be converted to physical length, you need to specify the accuracy dpi (Dots per inch, pixels per inch), when scanning printing generally have dpi optional. Windows system By default is 96dpi,apple system default is 72dpi. Relative length units. Pixel px is relative to the display screen resolution. (quoted from CSS2.0 manual)

PX Features:

IE cannot adjust the font size using PX as the unit;

Most of the foreign sites can be adjusted because of its use of EM or REM as a font unit;

Firefox can adjust PX and em,rem, but more than 96% of Chinese netizens use IE (or kernel).

PT (Point, LB): is a unit of physical length that refers to an inch of 72 points.

EM (relative length units, relative to the font size of the text within the current object): is a unit of relative length, originally referred to as the width of the letter m, hence the name EM. Now refers to a multiple of the width of the character, using a similar percentage, such as: 0.8em, 1.2em,2em and so on. Usually 1em=16px.

The font size relative to the text within the current object. If the font size of the current inline text is not artificially set, the default font size is relative to the browser. (quoted from CSS2.0 manual)

em features :

The value of EM is not fixed;

EM inherits the font size of the parent element.

"The default font height for any browser is 16px. All non-adjustable browsers are compliant with: 1EM=16PX. So 12px=0.75em,10px=0.625em. To simplify the conversion of font-size, you need to declare font-size=62.5% in the body selector in the CSS, which makes the EM value 16px*62.5%=10px, so 12px=1.2em, 10px=1em, That means you just have to divide your original PX value by 10 and then put EM in as the unit. "(EXT)

So when we are writing CSS, we need to pay attention to two points:

The body selector declares the font-size=62.5%;

Divide your original PX value by 10 and then replace it with EM as the unit;

Recalculate the EM values of those magnified fonts. Avoid duplicate declarations of font size.

Font Size: is a unique unit in the Chinese font, in Chinese code to denote a specific point of Point pt, easy to remember, Express.

The conversion formula for PT and PX can be derived according to the PT definition:

PT=1/72 (inches), px=1/dpi (inches)

So pt=px*72/dpi

Calculated as 96dpi under Windows, PT=PX*72/96=PX*3/4

REM: is a new relative unit of CSS3 (root em, root em), and this unit has aroused wide concern.

What is the difference between this unit and EM?

The difference is that when you use REM to set the font size for an element, it is still relative size, but relative to the HTML root element. This unit is a combination of relative size and absolute size of the advantages in one, through it can only modify the root elements in proportion to adjust all font size, but also to avoid the size of the font-layer composite chain reaction. Currently, in addition to IE8 and earlier versions, all browsers support REM. For browsers that do not support it, the workaround is simple enough to write an absolute unit statement. These browsers ignore font sizes that are set with REM.

Original link

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.