HTML属性

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'

  • The href Attribute
    This is a link ---> This is a link

  • The src Attribute

  • The width and height Attributes
    --> The image size is specified in pixels: width="500" means 500 pixels wide.

  • The alt Attribute (The alt attribute specifies an alternative text to be used, when an image cannot be displayed.The value of the attribute can be read by screen readers. This way, someone "listening" to the webpage, e.g. a blind person, can "hear" the element.)
    Girl with a jacket --> If we try to display an image that does not exist, the value of the alt attribute will be displayed instead.

  • The style Attribute (The style attribute is used to specify the styling of an element, like color, font, size etc.)

    I am a paragraph

  • The lang Attribute (The language of the document can be declared in the tag. The language is declared with the lang attribute. Declaring a language is important for accessibility applications (screen readers) and search engines.)





...



  • The title Attribute (Here, a title attribute is added to the

    element. The value of the title attribute will be displayed as a tooltip when you mouse over the paragraph.)

This is a paragraph.

Summary

  • All HTML elements can have attributes
  • The title attribute provides additional "tool-tip" information
  • The href attribute provides address information for links
  • The width and height attributes provide size information for images
  • The alt attribute provides text for screen readers

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 标准属性参考手册.

你可能感兴趣的:(HTML属性)