html[Attributes Style]什么意思

前言:我个人是一个执着 喜欢钻牛角尖的人,即使遇到的问题并不影响我继续学习,但是不弄清楚它,心里感谢很不舒服。在遇到该问题时,我首先去网络上寻找答案,没想到全网就找到这一个解答html[Attributes Style]是什么意思?,回答有点儿简单,没有解决我的问题。于是,我去“外面”找答案,也只找到了这一个解答:What does -webkit-locale mean in css? ,同样没有完全解决我的疑惑。不过,它们有很多值得参考的内容。最后,在查找了很多官方文档和其他相关网站后,才有了本篇文章。

一、问题发生

当我使用Google Chrome浏览器检查html元素时,发现了如下图所示的样式。我并没有在html代码中显式的书写该样式,这应该是Chrome浏览器背地里添加的样式。

在这里插入图片描述

二、问题分析

我在看到这个样式时,我首先产生的问题是:**[Attributes Style]**是什么意思?其次产生的问题是: -webkit-locale有什么作用?接下来的内容主要围绕这两个问题展开。

1、Attributes Style是什么样式

在回答这个问题之前,我们先回顾下元素属性的相关知识。

在这里插入图片描述

元素(本例是p元素)可以拥有属性(Attribute),属性为元素补充额外信息,这些信息不希望在内容中显示。

Class、id等类型的属性主要用于选择器定位元素;action、method、href等类型的属性发挥某种特定的功能;

还有一种属性,例如width、height、bgcolor等等,这类属性主要用于设置元素的样式。然而,现今设置样式应该是CSS的工作,这种类型的属性成为了遗留属性,主要在旧版本HTML中使用。现在,已经不提倡使用这类属性,设置样式应该使用CSS。但是,某些场景下这类属性有些还在使用,例如<canvas></canvas> (JavaScritp使用该元素绘制图形及图形动画) 必须使用height属性指定高度。

下面,我们以img元素为例,设置宽度和高度属性

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body>
    <img src="" alt="" width="100px" height="100px">
</body>
</html>

使用Chrome浏览器检查该元素
在这里插入图片描述

显示效果,如下图所示,aspect-ratio: auto 100 / 100;是Chrome浏览器自己添加的属性,应该就是左上角的小图片。Firefox浏览器不会添加如此的小图片。

在这里插入图片描述

CSS 基本语法

在这里插入图片描述

综上所述

在Chrome浏览器中以及使用webkit、blink内核的浏览器中,Attribute Style 就是由某些元素属性(Attribute)转换而来的样式属性(property)。

我之所以强调在Chrome浏览器以及使用webkit、blink内核的浏览器,是因为在某些浏览器中,例如FireFox,并不一定存在Attibute Style,图片有宽高,说明元素属性生效了,但是它并没有把元素属性作为样式来处理。

在这里插入图片描述

2. -webkit-locale=en 有什么作用

它属于从元素属性(attribute)转换而来样式属性(property),而我们上文中的代码html元素中只定义了一个属性lang=en,因此 -webkit-locale: enlang=en 作用相同,用于设置元素使用的语言。本例中,是给html元素添加的属性,就是说设置了整个网页内容主要使用的语言是英文。文档的其他元素,例如p元素,也是可以单独添加自己的lang属性。

关于lang属性以及相关知识:lang伪类的使用方法,有许多内容需要讲解,篇幅可能比本文还要大,这样就偏离了文章主题。因此,我会单独写一篇文章介绍下这部分知识。

到此,问题已基本解决。不过还有许多相关的拓展知识可以挖掘。感兴趣可以继续阅读~

三、拓展知识

1、规范属性、试验性属性、私有属性

我们在CSS中使用的属性(property),通常包含下列三类:

  1. 规范属性,发布的CSS规范中定义的属性
  2. 试验性属性,已在规范的草案中定义,将来可能会标准化。
  3. 私有属性,浏览器厂商自己定义的属性,没有在规范或者规范的草案中出现。

在试验性属性还未标准化时,部分浏览器已经根据最初草案实现了它们的部分功能,为了与之后确定下来的规范属性进行兼容,所以每种浏览器给实验性属性添加自己的私有前缀与规范属性进行区分,当规范属性确立后,各大浏览器将逐步支持不带前缀的CSS新属性。私有,私有前缀也用于各浏览器厂商自己定义的私有属性。各浏览器使用的私有前缀,如下所示

  • -ms- IE浏览器
  • -moz- Firefox浏览器器
  • -webkit- Google浏览器、Safril浏览器
  • -o- Opera浏览器

2. Chrome浏览器中的CSS样式来源

Chrome浏览器或者使用webkit、blink内核的浏览器使用的样式的来源。Firefox浏览兰奇除了没有属性转换的样式,其他来源也都具有。
在这里插入图片描述

  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
org.htmlparser.Tag org.htmlparser.Node org.htmlparser.Text org.htmlparser.Parser org.htmlparser.Remark org.htmlparser.tags.Div org.htmlparser.Attribute org.htmlparser.tags.Html org.htmlparser.tags.Span org.htmlparser.NodeFilter org.htmlparser.lexer.Page org.htmlparser.NodeFactory org.htmlparser.http.Cookie org.htmlparser.lexer.Lexer org.htmlparser.sax.Locator org.htmlparser.tags.Bullet org.htmlparser.tags.JspTag org.htmlparser.lexer.Cursor org.htmlparser.lexer.Source org.htmlparser.lexer.Stream org.htmlparser.sax.Feedback org.htmlparser.tags.BodyTag org.htmlparser.tags.FormTag org.htmlparser.tags.HeadTag org.htmlparser.tags.LinkTag org.htmlparser.tags.MetaTag org.htmlparser.nodes.TagNode org.htmlparser.sax.XMLReader org.htmlparser.tags.FrameTag org.htmlparser.tags.ImageTag org.htmlparser.tags.InputTag org.htmlparser.tags.LabelTag org.htmlparser.tags.StyleTag org.htmlparser.tags.TableRow org.htmlparser.tags.TableTag org.htmlparser.tags.TitleTag org.htmlparser.util.NodeList org.htmlparser.beans.LinkBean org.htmlparser.nodes.TextNode org.htmlparser.sax.Attributes org.htmlparser.tags.AppletTag org.htmlparser.tags.ObjectTag org.htmlparser.tags.OptionTag org.htmlparser.tags.ScriptTag org.htmlparser.tags.SelectTag org.htmlparser.util.Translate org.htmlparser.util.sort.Sort org.htmlparser.beans.BeanyBaby org.htmlparser.http.HttpHeader org.htmlparser.lexer.PageIndex org.htmlparser.tags.BulletList org.htmlparser.tags.DoctypeTag org.htmlparser.tags.HeadingTag org.htmlparser.util.NodeList$1 org.htmlparser.beans.FilterBean org.htmlparser.beans.StringBean org.htmlparser.filters.OrFilter org.htmlparser.nodes.RemarkNode org.htmlparser.scanners.Scanner org.htmlparser.tags.BaseHrefTag org.htmlparser.tags.FrameSetTag org.htmlparser.tags.TableColumn org.htmlparser.tags.TableHeader org.htmlparser.tags.TextareaTag org.htmlparser.util.ParserUtils org.htmlparser.beans.BeanyBaby$1 org.htmlparser.filters.AndFilter org.htmlparser.filters.NotFilter org.htmlparser.filters.XorFilter org.htmlparser.tags.CompositeTag org.htmlparser.tags.ParagraphTag org.htmlparser.util.IteratorImpl org.htmlparser.util.NodeIterator org.htmlparser.visitors.HtmlPage org.htmlparser.util.sort.Ordered org.htmlparser.beans.HTMLLinkBean org.htmlparser.beans.HTMLTextBean org.htmlparser.lexer.StringSource org.htmlparser.nodes.AbstractNode org.htmlparser.util.sort.Sortable org.htmlparser.filters.RegexFilter org.htmlparser.lexer.PageAttribute org.htmlparser.scanners.JspScanner org.htmlparser.scanners.TagScanner org.htmlparser.tags.DefinitionList org.htmlparser.util.NodeTreeWalker org.htmlparser.util.ParserFeedback org.htmlparser.filters.StringFilter org.htmlparser.util.FeedbackManager org.htmlparser.util.ParserException org.htmlparser.visitors.NodeVisitor org.htmlparser.filters.IsEqualFilter org.htmlparser.filters.TagNameFilter org.htmlparser.scanners.StyleScanner org.htmlparser.util.ChainedException org.htmlparser.filters.HasChildFilter org.htmlparser.http.ConnectionManager org.htmlparser.http.ConnectionMonitor org.htmlparser.scanners.ScriptDecoder org.htmlparser.scanners.ScriptScanner org.htmlparser.PrototypicalNodeFactory org.htmlparser.filters.HasParentFilter org.htmlparser.filters.LinkRegexFilter org.htmlparser.filters.NodeClassFilter org.htmlparser.lexer.InputStreamSource org.htmlparser.util.CharacterReference org.htmlparser.util.SimpleNodeIterator org.htmlparser.filters.HasSiblingFilter org.htmlparser.filters.LinkStringFilter org.htmlparser.tags.DefinitionListBullet org.htmlparser.util.CharacterReferenceEx org.htmlparser.filters.HasAttributeFilter org.htmlparser.util.DefaultParserFeedback org.htmlparser.visitors.TagFindingVisitor org.htmlparser.visitors.LinkFindingVisitor org.htmlparser.scanners.CompositeTagScanner org.htmlparser.util.EncodingChangeException org.htmlparser.visitors.UrlModifyingVisitor org.htmlparser.filters.CssSelectorNodeFilter org.htmlparser.tags.ProcessingInstructionTag org.htmlparser.visitors.ObjectFindingVisitor org.htmlparser.visitors.StringFindingVisitor org.htmlparser.visitors.TextExtractingVisitor org.htmlparser.filters.CssSelectorNodeFilter$1 org.htmlparser.parserapplications.SiteCapturer org.htmlparser.parserapplications.WikiCapturer org.htmlparser.parserapplications.LinkExtractor org.htmlparser.parserapplications.LinkExtractor$1 org.htmlparser.parserapplications.StringExtractor org.htmlparser.filters.CssSelectorNodeFilter$YesFilter org.htmlparser.parserapplications.filterbuilder.Filter org.htmlparser.filters.CssSelectorNodeFilter$AdjacentFilter org.htmlparser.parserapplications.SiteCapturer$LocalLinkTag org.htmlparser.parserapplications.SiteCapturer$LocalFrameTag org.htmlparser.parserapplications.SiteCapturer$LocalImageTag org.htmlparser.parserapplications.filterbuilder.FilterBuilder org.htmlparser.parserapplications.filterbuilder.HtmlTreeModel org.htmlparser.parserapplications.filterbuilder.SubFilterList org.htmlparser.filters.CssSelectorNodeFilter$AttribMatchFilter org.htmlparser.filters.CssSelectorNodeFilter$HasAncestorFilter org.htmlparser.parserapplications.SiteCapturer$LocalBaseHrefTag org.htmlparser.parserapplications.filterbuilder.HtmlTreeCellRenderer org.htmlparser.parserapplications.filterbuilder.wrappers.OrFilterWrapper org.htmlparser.parserapplications.filterbuilder.layouts.NullLayoutManager org.htmlparser.parserapplications.filterbuilder.wrappers.AndFilterWrapper org.htmlparser.parserapplications.filterbuilder.wrappers.NotFilterWrapper org.htmlparser.parserapplications.filterbuilder.wrappers.RegexFilterWrapper org.htmlparser.parserapplications.filterbuilder.wrappers.StringFilterWrapper org.htmlparser.parserapplications.filterbuilder.layouts.VerticalLayoutManager org.htmlparser.parserapplications.filterbuilder.wrappers.TagNameFilterWrapper org.htmlparser.parserapplications.filterbuilder.wrappers.HasChildFilterWrapper org.htmlparser.parserapplications.filterbuilder.wrappers.HasParentFilterWrapper org.htmlparser.parserapplications.filterbuilder.wrappers.NodeClassFilterWrapper org.htmlparser.parserapplications.filterbuilder.wrappers.HasSiblingFilterWrapper org.htmlparser.parserapplications.filterbuilder.wrappers.HasAttributeFilterWrapper
此书属网上搜集,供鉴赏之用,请勿保存,如触及到法律,本人概不负责,如喜欢 请购买正版。 目录: Introduction Chapter 1. Purpose Section A. Conceptual overview Section B. Technical overview Section C. JavaScript history Chapter 2. Context Section A. The CSS revolution Section B. Separation of presentation and structure Section C. Separation of behavior and structure Section D. Separation of behavior and presentation Section E. Accessibility overview Section F. Rules of accessibility Section G. The example scripts Chapter 3. Browsers Section A. The browsers Section B. Incompatibilities Section C. Object detection Section D. Browser detection Section E. Debugging Chapter 4. Preparation Section A. HTML and CSS structure Section B. Hooks Section C. Preparing the page Section D. The <script> tag Section E. Initialization Section F. The example scripts Chapter 5. Core Section A. The basics Section B. Data types Section C. Common operators Section D. Variables Section E. Working with numbers Section F. Working with strings Section G. Working with booleans Section H. Control structures Section I. Functions Section J. Objects Section K. Associative arrays Section L. Arrays Chapter 6. BOM Section A. The window object Section B. Cross-window communication Section C. Navigation Section D. Window geometry Section E. Miscellaneous Section F. The document object Section G. Cookies Chapter 7. Events Section A. Browser incompatibilities Section B. The events Section C. Event-handler registration Section D. Event bubbling and capturing Section E. The event object and its properties Section F. Targeting Section G. The example scripts Section H. Dropdown Menu, mouseouts, and the related target Chapter 8. DOM Section A. Concepts Section B. Finding elements Section C. Node information Section D. Changing the document tree Section E. Creating and cloning elements Section F. innerHTML Section G. Attributes Section H. Text nodes Section I. nodeLists Section J. Forms and the Level 0 DOM Section K. DOM hyperspace Section L. Markers Chapter 9. CSS modification Section A. The style property Section B. Changing classes and ids Section C. Writing CSS into the page Section D. Changing entire style sheets Section E. Comparison Section F. Showing and hiding elements Section G. Animations Section H. Dimensions and position of elements Chapter 10. Data retrieval Section A. Sending the request Section B. Handling the response Section C. The response format Section D. Accessibility Afterword The future of JavaScript

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

明月几时有666

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值