HTML Attributes

来源:互联网 发布:htc刷机救砖软件 编辑:程序博客网 时间:2024/06/12 10:28

HTML Attributes (case-insensitive 大小写不敏感)

  • Attributes provide additional information about an element, always specified in the start tag
  • Attributes come in name/value pairs like: name="value"


land 属性

The document language can be declared in the <html> tag with thelang attribute.

Declaring a language is important for accessibility applications (screen readers) and search engines.

文档语言可以被定义在 <html> 标签里。定义文档语言,对于屏幕阅读器和搜索引擎可获取性很重要。


alt 属性

The alt attribute specifies an alternative text to be used, when an HTML element cannot be displayed. The value of the attribute can be read by "screen readers".
该属性设定了可被使用的替换文本,当该元素的内容无法展示时。同时 alt 的值还能被屏幕阅读器读取。


引号

HTML 5 并没有要求属性的值要被引号限制起来,但是,最好记得使用引号。

<p title=About W3Schools>

避免由属性值里面的空格引起的显示错误。


单/双引号

Double style quotes are the most common, butsingle style quotes are also allowed

通常使用双引号,但是单引号也是被允许的。

Tip: In some rare situations, when the attribute value itself contains quotes, it is necessary to use single quotes

<p title='John "ShotGun" Nelson'>

当属性值包含双引号,则必须使用单引号把它括起来。


小写

W3Crecommends lowercase in HTML4, and demands lowercase for stricter document types like XHTML.

因此,尽管HTML 5没有要求属性要小写,通常使用小写的属性名称。


HTML Global Attributes(常用的适用于任何HTML元素的属性):

classone or more class names for an element (refers to a class in a style sheet)ida unique id for an elementstylean inline CSS style for an elementtitleextra information 额外信息 about an element (when mouse over the element, title displayed as a tool tip 提示框)


0 0