search
HomeWeb Front-endHTML TutorialHow to express length in html? Several common length representation methods in html


#How to express length in html? What are some common length representation methods in HTML? This article brings you content about the HTML medium length method. I hope it will be of some help to you.

The following is a summary of pCSS5’s introduction to common html units in web pages and an introduction to length units in css p layout.

In fact, there are 8 length units in CSS, namely px, em, pt, ex, pc, in, mm, cm;

px: pixel (Pixel), relative to the length unit of the device, pixels are relative to the display screen resolution. For example, the resolution used by WONDOWS users is generally 96 pixels/inch. The resolution used by MAC users is generally 72 pixels/inch.
em: Relative length unit. The font size relative to the text within the current object. If the font size of the current inline text has not been manually set, it is relative to the browser's default font size.
ex: Relative length unit. Height relative to character "x". This height is usually half the font size. If the current font size for inline text has not been manually set, it will be relative to the browser's default font size.
pt: Point, absolute unit of length.
pc: Pica, absolute unit of length. It is equivalent to the size of my country's new No. 4 type.
in: Inch, absolute unit of length.
mm: Millimeter, absolute unit of length.
cm: Centimeter, absolute unit of length.

Among them: 1in = 2.54cm = 25.4 mm = 72pt = 6pc;

We often use px as the unit for the size of the container, and everyone has no objection. The font size (font-size) is many domestically Many people use px as the unit. In fact, the only fatal disadvantage of using px as the font unit is that the browser font scaling function cannot be used under IE. Or hold down Ctrl and scroll the middle wheel of the mouse.

So many people suggest using html em units. For people who are used to using px, it is definitely not very convenient to use em. Here are some conversion formulas and comparison tables for your reference:

px to em :Example: 12px / 16px = .75em
px to %:Example: 12px / 16px * 100 = 75%
px to pt:Example: 16px * 72 (72 points = 1 inch) / 96 (96 pixels per inch in Windows, 72 in Mac) = 12pt
em to px:Example: .75em * 16px = 12px
em to %:Example: .75em * 100 = 75%
% to px:Example : 75 * 16px / 100 = 12px
% to em:Example: 75 / 100 = .75em
pt to px:Example: 12pt * 96ppi / 72ppi = 16px

##9px0.563em56.3%7pt##10px11px12px13px14px15px16px##17px1.063em106.3% 13pt18px1.125em112.5%14pt19px1.188em118.8%14pt20px1.25em 125%15pt21px1.313em131.3% 16pt22px1.375em137.5%17pt1.438em1.5emFinally pCSS5RecommendationUse
Pixels EMs Percent Points
6px 0.375em 37.5% 5pt
7px 0.438em 43.8% 5pt
8px 0.5em 50% 6pt
0.625em 62.5% 8pt
0.688em 68.8% 8pt
0.75em 75% 9pt
0.813em 81.3% 10pt
0.875em 87.5% 11pt
0.938em 93.8% 11pt
1em 100% 12pt
##23px
143.8% 17pt 24px
150% 18pt
PX pixels

to lay out the web page in units: Personally think that the disadvantage of using px as the font unit and not being able to use the browser font scaling function under IE is no longer so important. Because the new versions of IE7 and IE8 already support the zoom function of the entire web page, including Firefox, which zooms the entire web page by default instead of scaling CSS fonts. Is there any significance in not simply scaling the font size? For more related tutorials, please visit:

http://www.php.cn/course/list/11.html

The above is How to express length in html? A complete introduction to several common length representation methods in HTML. If you want to know more about HTML tutorials, please pay attention to the PHP Chinese website.

The above is the detailed content of How to express length in html? Several common length representation methods in html. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:divcss5. If there is any infringement, please contact admin@php.cn delete
What is the purpose of the <datalist> element?What is the purpose of the <datalist> element?Mar 21, 2025 pm 12:33 PM

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <progress> element?What is the purpose of the <progress> element?Mar 21, 2025 pm 12:34 PM

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

What is the purpose of the <meter> element?What is the purpose of the <meter> element?Mar 21, 2025 pm 12:35 PM

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

What is the purpose of the <iframe> tag? What are the security considerations when using it?What is the purpose of the <iframe> tag? What are the security considerations when using it?Mar 20, 2025 pm 06:05 PM

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

How do I use HTML5 form validation attributes to validate user input?How do I use HTML5 form validation attributes to validate user input?Mar 17, 2025 pm 12:27 PM

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

What is the viewport meta tag? Why is it important for responsive design?What is the viewport meta tag? Why is it important for responsive design?Mar 20, 2025 pm 05:56 PM

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

What are the best practices for cross-browser compatibility in HTML5?What are the best practices for cross-browser compatibility in HTML5?Mar 17, 2025 pm 12:20 PM

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

How do I use the HTML5 <time> element to represent dates and times semantically?How do I use the HTML5 <time> element to represent dates and times semantically?Mar 12, 2025 pm 04:05 PM

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),