1. Introduction
The size units in css given in w3cschool are as follows:
% | Percent | ||||||||||||||||||
in | inch | ||||||||||||||||||
cm | cm td> | ||||||||||||||||||
mm | mm | ||||||||||||||||||
em |
2em is equal to twice the current font size. For example, if an element is displayed in 12pt, then 2em is 24pt. In CSS, em is a very useful unit because it automatically adapts to the font the user is using.
| ||||||||||||||||||
ex | An ex is the x-height of a font. (x-height is usually half the font size.) | ||||||||||||||||||
pt | Points (1 pt equals 1/72 inch) | tr>||||||||||||||||||
pc | 12-point movable type (1 pc equals 12 points) | ||||||||||||||||||
px | Pixel ( A dot on the computer screen) |
em is used to adapt to the font used by the user. 1em is equivalent to the current font size (font-size attribute), and 2em is equivalent to twice the current font size.
h1 { font-size: 2em; margin: .67em 0 }h2 { font-size: 1.5em; margin: .75em 0 }h3 { font-size: 1.17em; margin: .83em 0 }h4, p,blockquote, ul,fieldset, form,ol, dl, dir,menu { margin: 1.12em 0 }h5 { font-size: .83em; margin: 1.5em 0 }h6 { font-size: .75em; margin: 1.67em 0 }h1, h2, h3, h4,h5, h6, b,strong { font-weight: bolder }Visible ems are used as relative sizes for specific fonts. 2. Examples
In the article Default Browser Styles, many default styles are in units of em.
Now take one of the default styles as an example.
It can be seen that in addition to font-weight bolding, the title series also has font-size settings and margin reservations. Now let’s take a look at h1’s font-size and margin reservations.
As you can see from the picture above, by default, h1 has font-size:32px;margin-bottom:21.44px; how does this value come from? ? Answer it below.
The relative unit em is relative to the font size of the element itself. The only exception in CSS is the font-size attribute, whose em and ex values refer to the font size relative to the parent element.
Look at the default style of h1 in chrome
The default font-size of h1: 2em, relative to the parent element, here the parent element body font-size:16px; (default value), so calculate the font-size:32px of h1.
The em calculation of other attributes except font-size is relative to the element's own font size. So the calculated value of margin-bottom:0.67em is 0.67*32px=21.44px.
3. Resource links
Rem VS PxPowerful em in css
The author of this article starof, because of the knowledge itself Changes, the author is constantly learning and growing, and the content of the article is also updated from time to time. In order to avoid misleading readers and facilitate tracing the source, please indicate the source when reprinting: If you have any questions, feel free to discuss with me and make progress together.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6
Visual web development tools

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),

Zend Studio 13.0.1
Powerful PHP integrated development environment