HTML属性

2018-06-26  本文已影响10人  春暖花开奇奇乐乐

HTML Attributes

All HTML elements can have attributes
Attributes provide additional information about an element
Attributes are always specified in the start tag
Attributes usually come in name/value pairs like: name="value" 属性总是以名称/值对的形式出现,比如:name="value"。
双引号是最常用的,不过使用单引号也没有问题。
提示: 在某些个别的情况下,比如属性值本身就含有双引号,那么您必须使用单引号,例如:name='John "ShotGun" Nelson'

<!DOCTYPE html>
<html lang="en-US">
<body>

...

</body>
</html>
<p title="I'm a tooltip">
This is a paragraph.
</p>

Summary

Attribute Description

alt Specifies an alternative text for an image, when the image cannot be displayed
disabled Specifies that an input element should be disabled
href Specifies the URL (web address) for a link
id Specifies a unique id for an element 定义元素的唯一id
src Specifies the URL (web address) for an image
style Specifies an inline CSS style for an element 规定元素的行内样式(inline style)
title Specifies extra information about an element (displayed as a tool tip) 描述了元素的额外信息 (作为工具条使用)

A complete list of all attributes for each HTML element, is listed in our: HTML Attribute Reference.
更多 HTML 标准属性说明: HTML 标准属性参考手册.

上一篇 下一篇

猜你喜欢

热点阅读