Analysis of conversion between length units in CSS

Source: Internet
Author: User
Tags comparison table
When writing CSS, the most commonly used length units are px (pixels), often see EM,PT and so on, in fact, the length of the CSS in a total of 8, respectively, is px,em,pt,ex,pc,in,mm,cm.
1, px: pixels (Pixel), relative to the device's length unit, pixels are relative to the display screen resolution.
For example, the resolution used by wondows users is typically 96 pixels per inch. The resolution used by Mac users is typically 72 pixels per inch.
2, EM: relative length unit. 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.
3, PT: Point, Absolute length unit.
4. Ex: unit of relative length. The height relative to the character "X". This height is usually half the size of the font.
If the font size of the current inline text is not artificially set, the default font size is relative to the browser.
5, PC: Dispatch card (Pica), absolute length unit. Equivalent to the size of our new No. fourth.
6, In: inches (inch), absolute length units.
7, MM: mm (millimeter), absolute length units.
8, CM: cm (centimeter), absolute length unit.
Where: 1in = 2.54cm = 25.4 mm = 72pt = 6pc;
The size of the container we often use PX to do the unit; font size (font-size) Many people use PX to do units, in fact, the only fatal disadvantage of using PX to do font units is the ability to zoom in browser font under IE.
However, it is no longer important for the individual to think that the function of using PX to do the font size in IE cannot be scaled with browser font. Because the new version of IE7,IE8 has supported the entire Web page zoom function, including Firefox by default is also scaling the entire Web page, instead of scaling the font, not so simple to scale the size of the font is there any significant significance? Hold down CTRL + Scroll the middle wheel of the mouse to try it! IE has progressed!

In fact, the length of the CSS in a total of 8 units, respectively, is px,em,pt,ex,pc,in,mm,cm;
PX: pixels (Pixel), relative to the device's unit of length, pixels are relative to the display screen resolution. For example, the resolution used by wondows users is typically 96 pixels per inch. The resolution used by Mac users is typically 72 pixels per inch.
EM: Relative length units. 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.
Ex: unit of relative length. The height relative to the character "X". This height is usually half the size of the font. If the font size of the current inline text is not artificially set, the default font size is relative to the browser.
PT: Point, Absolute length unit.
PC: Dispatch card (Pica), absolute length unit. Equivalent to the size of our new No. fourth.
In: inches (inch), absolute length units.
MM: mm (millimeter), absolute length unit.
CM: cm (centimeter), absolute length unit.
Where: 1in = 2.54cm = 25.4 mm = 72pt = 6pc;
The size of the container we often use PX to do units, we all have no objection, font size (font-size) A lot of domestic people use PX to do units, in fact, using PX to do font unit of the only fatal disadvantage is in IE can not use browser font zoom function. or press and hold CTRL + scroll the mouse in the middle of the wheel.
So many people recommend the use of HTML EM units, for the use of the PX people with EM is certainly not very convenient, here are some conversion formula and a comparison table for your reference:

px to em:example:12px/16px =. 75empx to%:example:12px/16px * + = 75%px to PT : example:16px * (points = 1 inch)/(pixels per inch in Windows, and in Mac) = 12ptem to www.hnnedu.com px:exa Mple:. 75em * 16px = 12pxem to%:example:. 75em * + = 75%% to px:example:75 * 16px/100 = 12px% to EM:EXAMPLE:75/10 0 =. 75empt to px:example:12pt * 96ppi/72ppi = 16PXPIXELSEMSPERCENTPOINTS6PX0.375EM37.5%5PT7PX0.438EM43.8%5PT8PX0.5EM5 0%6pt9px0.563em56.3%7pt10px0.625em62.5%8pt11px0.688em68.8%8pt12px0.75em75%9pt13px0.813em81.3% 10pt14px0.875em87.5%11pt15px0.938em93.8%11pt16px1em100%12pt17px1.063em106.3%13pt18px1.125em112.5% 14pt19px1.188em118.8%14pt20px1.25em125%15pt21px1.313em131.3%16pt22px1.375em137.5%17pt23px1.438em143.8% 17pt24px1.5em150%18pt 
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.