css property 和 attribute 的区别-阿里云开发者社区

开发者社区> 努力滴码农> 正文

css property 和 attribute 的区别

简介: css property 和 attribute 的区别
+关注继续查看

css property可以包含下列这些属性:


Value: legal values & syntax


Initial: initial value


Applies to: elements this property applies to


Inherited: whether the property is inherited


Percentages: how percentage values are interpreted - 是否接受百分号作为属性值


Media: which media groups the property applies to


Computed value: how to compute the computed value


属性值定义的几种方式:


Several juxtaposed words mean that all of them must occur, in the given order.


A bar (|) separates two or more alternatives: exactly one of them must occur.


A double bar (||) separates two or more options: one or more of them must occur, in any order.


A double ampersand (&&) separates two or more components, all of which must occur, in any order.


Brackets ([ ]) are for grouping.



font-family: "Gill Sans", sans-serif; - 通用字体,所有浏览器都支持


image.png

User Agent, 即浏览器。

The first declaration on the BODY element sets the font family to “Gill Sans”. If that font is not available, the user agent (often referred to as a “browser”) will use the ‘sans-serif’ font family which is one of five generic font families which all users agents know. Child elements of BODY will inherit the value of the ‘font-family’ property.


Attribute

A value associated with an element, consisting of a name, and an associated (textual) value.


Content

The content associated with an element in the source document. Some elements have no content, in which case they are called empty.


The content of an element may include text, and it may include a number of sub-elements, in which case the element is called the parent of those sub-elements.


Author

An author is a person who writes documents and associated style sheets. An authoring tool is a User Agent that generates style sheets.


css的书写者。


User

A user is a person who interacts with a user agent to view, hear, or otherwise use a document and its associated style sheet. The user may provide a personal style sheet that encodes personal preferences.


最终用户


User agent (UA)

A user agent is any program that interprets a document written in the document language and applies associated style sheets according to the terms of this specification. A user agent may display a document, read it aloud, cause it to be printed, convert it to another format, etc.


An HTML user agent is one that supports one or more of the HTML specifications. A user agent that supports XHTML [XHTML], but not HTML is not considered an HTML user agent for the purpose of conformance with this specification.


Property

CSS defines a finite set of parameters, called properties, that direct the rendering of a document.


Each property has a name (e.g., ‘color’, ‘font’, or border’) and a value (e.g., ‘red’, ‘12pt Times’, or ‘dotted’). Properties are attached to various parts of the document and to the page on which the document is to be displayed by the mechanisms of specificity, cascading, and inheritance (see the chapter on Assigning property values, Cascading, and Inheritance).


CSS property和document渲染相关,但attribute无关。


看个attribute的例子:

image.png

percentage property

Percentage values are always relative to another value, for example a length.


Percentage values总是和另一个属性值相关联。


Each property that allows percentages also defines the value to which the percentage refers. The value may be that of another property for the same element, a property for an ancestor element, or a value of the formatting context (e.g., the width of a containing block).


比如我指定了一个max-wdith:60%,那么这个60%到底是另一个什么样的属性的60%呢?


另一个属性可能是同一个element的另一个属性,也可能是其祖先element的某一个属性,或者是formatting context的value,比如containing block的width.


When a percentage value is set for a property of the root element and the percentage is defined as referring to the inherited value of some property, the resultant value is the percentage times the initial value of that property.


percentage value的继承问题

Since child elements (generally) inherit the computed values of their parent, in the following example, the children of the P element will inherit a value of 12px for ‘line-height’, not the percentage value (120%):

image.png

子节点继承父节点的property是calculated property,而不是percentage property.


版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
阿里云服务器怎么设置密码?怎么停机?怎么重启服务器?
如果在创建实例时没有设置密码,或者密码丢失,您可以在控制台上重新设置实例的登录密码。本文仅描述如何在 ECS 管理控制台上修改实例登录密码。
10095 0
阿里云服务器端口号设置
阿里云服务器初级使用者可能面临的问题之一. 使用tomcat或者其他服务器软件设置端口号后,比如 一些不是默认的, mysql的 3306, mssql的1433,有时候打不开网页, 原因是没有在ecs安全组去设置这个端口号. 解决: 点击ecs下网络和安全下的安全组 在弹出的安全组中,如果没有就新建安全组,然后点击配置规则 最后如上图点击添加...或快速创建.   have fun!  将编程看作是一门艺术,而不单单是个技术。
10886 0
Django的Project和App的区别
Django的Project和App的区别
1080 0
x3d
[转]代理(Proxy)和委派(Delegate)的区别
模式是程序员之间的交流语言,代理(Proxy)和委派(Delegate)是模式中常见的词汇,不过很多人把他们混淆了,甚至等同起来,这会造成很多沟通交流上的误解,下面说说他们的区别,先看一个UML图: 图形已经表述的很直白了,如果还不清晰,可以看看下面的代码: 01 interface Subject...
1656 0
阿里云服务器如何登录?阿里云服务器的三种登录方法
购买阿里云ECS云服务器后如何登录?场景不同,阿里云优惠总结大概有三种登录方式: 登录到ECS云服务器控制台 在ECS云服务器控制台用户可以更改密码、更换系.
13893 0
jQ中attr与prop的区别
先说一说官方定义.attr()获取匹配的元素集合中的第一个元素的属性值,设置每个匹配元素的一个或多个属性.p
31 0
promise 和 Observable 的区别
promise 和 Observable 的区别
13 0
阿里云ECS云服务器初始化设置教程方法
阿里云ECS云服务器初始化是指将云服务器系统恢复到最初状态的过程,阿里云的服务器初始化是通过更换系统盘来实现的,是免费的,阿里云百科网分享服务器初始化教程: 服务器初始化教程方法 本文的服务器初始化是指将ECS云服务器系统恢复到最初状态,服务器中的数据也会被清空,所以初始化之前一定要先备份好。
11893 0
阿里云ECS云服务器初始化设置教程方法
阿里云ECS云服务器初始化是指将云服务器系统恢复到最初状态的过程,阿里云的服务器初始化是通过更换系统盘来实现的,是免费的,阿里云百科网分享服务器初始化教程: 服务器初始化教程方法 本文的服务器初始化是指将ECS云服务器系统恢复到最初状态,服务器中的数据也会被清空,所以初始化之前一定要先备份好。
7365 0
2497
文章
0
问答
来源圈子
更多
+ 订阅
文章排行榜
最热
最新
相关电子书
更多
《2021云上架构与运维峰会演讲合集》
立即下载
《零基础CSS入门教程》
立即下载
《零基础HTML入门教程》
立即下载