× 目录 [1]initial [2]inherit [3]unset [4]revert [5]all
前面的话
在CSS中,有4个关键字理论上可以应用于任何的CSS属性,它们是initial(初始)、inherit(继承)、unset(未设置)、revert(还原)。而all的取值只能是以上这4个关键字。本文将介绍initial、inherit、unset、revert和all
initial
表示元素属性的初始默认值(该默认值由官方CSS规范定义)
兼容性: IE不支持
[注意]关于各属性的初始默认值移步至此
//display在官方CSS规范中定义的默认值是inline<style>.test{display: initial;}</style><div class="box"> <div class="test">测试一</div><span>文字</span> <br> <div >测试二</div><span>文字</span></div>
inherit
表示元素的直接父元素对应属性的计算值
兼容性: IE7-不支持
<style>.box{ border: 1px solid black; padding: 10px; width: 100px;}.test{ border: inherit; height: 30px;}</style><div class="box"> <div class="test">测试一</div></div><div class="box"> <div class="in"> <div class="test">测试二</div> </div></div>
unset
unset相对于initial和inherit而言,相对复杂一点。表示如果该属性默认可继承,则值为inherit;否则值为initial。实际上,设置unset相当于不设置
兼容性: IE不支持,safari9-不支持,ios9.2-不支持,android4.4.4-不支持
【常用默认可继承样式】
colorcursordirectionfontletter-spacingline-heightlist-styletext-aligntext-indenttext-shadowtext-transformwhite-spaceword-breakword-spacingword-wrapwriting-mode
//内容为测试一的元素和内容为测试二的元素的样式是一样的<style>.box{ border: 1px solid black; padding: 10px; width: 100px; color: red;}.test1{ border: unset; color: unset;}</style><div class="box"> <div class="test">测试一</div> <div>测试二</div></div>
revert
表示样式表中定义的元素属性的默认值。若用户定义样式表中显式设置,则按此设置;否则,按照浏览器定义样式表中的样式设置;否则,等价于unset
兼容性: 只有safari9.1+和ios9.3+支持
all
表示重设除unicode-bidi和direction之外的所有CSS属性的属性值,取值只能是initial、inherit、unset和revert
兼容性: IE不支持,safari9-不支持,ios9.2-不支持,android4.4-不支持
<style>.test{ border: 1px solid black; padding: 20px; color: red;}.in{/* all: initial; all: inherit; all: unset; all: revert; */}</style><div class="test"> <div class="in">测试文字</div> </div>
【1】当all:initial时,.in的所有属性都取默认值
border:none;padding:0;color:black;
【2】当all:inherit时,.in的所有属性都取父元素继承值
border:1px solid black;padding:20px;color:red;
【3】当all:unset时,.in的所有属性都相当于不设置值,默认可继承的继承,不可继承的保持默认值
border:none;padding:0;color:red;

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.

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract


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

Zend Studio 13.0.1
Powerful PHP integrated development environment

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

Dreamweaver CS6
Visual web development tools

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.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft