New units added in css3: 1. "ch", the width of character 0; 2. "rem", a relative unit, mainly relative to the size of the root element font; 3. "vw", the window Width; 4. "vh", window height; 5. "vmin"; 6. "vmax", etc.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
New length units in CSS3
The new length units in CSS3 are as follows,
-
ch
, the width of character 0 rem
, is a relative unit, mainly relative to the size of the root element font, To use rem, we need to refer to the specified root element.vw
, viewpoint width, window width, 1vw=1% of the window widthvh
, viewpoint height, window height, 1vh=1% of the window heightvmin
,vmax
, etc.
The newly added viewpoint-related units are generally targeted at mobile devices.
rem
is actually the same thing as em
, except that rem
has an additional restriction, which represents the root element (html element) font-size. We can take a look at the difference between
rem
and em
through the following example,
<html style="font-size: 12px;"> <body> <div id="div1" style="font-size: 16px"> <div id="div2" style="font-size: 1.2em"></div> <div id="div3" style="font-size: 1.2rem"> <div id="div4" style="font-size: 1.2em"></div> </div> </div> </body> </html>
At this time,
font-size of div2:
16px*1.2em=19.2px
- ##font-size of div3:
12px*1.2 rem=14.4px
- font-size of div4:
12px*1.2rem*1.2em=17.28px
rem does not have a cascading relationship, but
em does.
rem units.
css video tutorial)
The above is the detailed content of What new units are added in css3. For more information, please follow other related articles on the PHP Chinese website!

The use of class selectors and ID selectors depends on the specific use case: 1) Class selectors are suitable for multi-element, reusable styles, and 2) ID selectors are suitable for unique elements and specific styles. Class selectors are more flexible, ID selectors are faster to process but may affect code maintenance.

ThekeygoalsandmotivationsbehindHTML5weretoenhancesemanticstructure,improvemultimediasupport,andensurebetterperformanceandcompatibilityacrossdevices,drivenbytheneedtoaddressHTML4'slimitationsandmeetmodernwebdemands.1)HTML5aimedtoimprovesemanticstructu

IDsareuniqueandusedforsingleelements,whileclassesarereusableformultipleelements.1)UseIDsforuniqueelementslikeaspecificheader.2)Useclassesforconsistentstylingacrossmultipleelementslikebuttons.3)BecautiouswithspecificityasIDsoverrideclasses.4)Useclasse

HTML5aimstoenhancewebaccessibility,interactivity,andefficiency.1)Itsupportsmultimediawithoutplugins,simplifyinguserexperience.2)Semanticmarkupimprovesstructureandaccessibility.3)Enhancedformhandlingincreasesusability.4)Thecanvaselementenablesdynamicg

HTML5isnotparticularlydifficulttousebutrequiresunderstandingitsfeatures.1)Semanticelementslike,,,andimprovestructure,readability,SEO,andaccessibility.2)Multimediasupportviaandelementsenhancesuserexperiencewithoutplugins.3)Theelementenablesdynamic2Dgr

No,youshouldn'tusemultipleIDsinthesameDOM.1)IDsmustbeuniqueperHTMLspecification,andusingduplicatescancauseinconsistentbrowserbehavior.2)Useclassesforstylingmultipleelements,attributeselectorsfortargetingbyattributes,anddescendantselectorsforstructure

HTML5aimstoenhancewebcapabilities,makingitmoredynamic,interactive,andaccessible.1)Itsupportsmultimediaelementslikeand,eliminatingtheneedforplugins.2)Semanticelementsimproveaccessibilityandcodereadability.3)Featureslikeenablepowerful,responsivewebappl

HTML5aimstoenhancewebdevelopmentanduserexperiencethroughsemanticstructure,multimediaintegration,andperformanceimprovements.1)Semanticelementslike,,,andimprovereadabilityandaccessibility.2)andtagsallowseamlessmultimediaembeddingwithoutplugins.3)Featur


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Dreamweaver Mac version
Visual web development tools

SublimeText3 Chinese version
Chinese version, very easy to use

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version
Recommended: Win version, supports code prompts!
