HTML attributesLOGIN

HTML attributes

HTML attributes

Attributes are additional information provided by HTML elements.

HTML attributes

HTML elements can set attributes

Attributes can add additional information to the element

Attributes are generally described in the opening tag

Attributes always appear in the form of name/value pairs, such as: name="value".

id specifies a unique identifier used to reference the element in CSS and scripts

class specifies a semantic class of which the element should be considered a member

style specifies The CSS style rules that should be applied to this element

title Specifies a title for the element

lang Specifies the natural language of the element's text content

dir Specifies the direction of the element's text content , left to right, or right to left

hidden Specifies whether the user agent should hide the content of the element

The language attribute lang, affects how punctuation is applied to the content of the element, including connections Font size, and selection of slurs and quotations. Content contained within a reference element displays a pair of different reference tags based on the value of the language attribute set for the element or inherited from its surrounding container. There is a conceptual distinction between the language of an element and the character set used to display the text on the page. The original use of the

title attribute was to provide a window title for links created by anchors and area elements that display non-HTML data (such as images, text files, directory listings, etc.). Internet Explorer was the first browser to display the value of the title attribute in a window tooltip when the user hovers the mouse over a link element. Users seem to love tooltips, and just for the sake of showing them, web developers provide them by wrapping elements in an anchor tag with an empty link. Considering the usefulness of the title attribute for search engine robots, the HTML4 specification extends its application to all HTML elements

HTML attributes commonly quoted attribute values

Attribute values ​​should always be enclosed in quotes.

Double quotes are the most commonly used, but there is no problem using single quotes.

Tip: In some individual cases, such as the attribute value itself contains double quotes, you must use single quotes, for example: name='John "ShotGun" Nelson'

HTML Tip: Use lowercase attributes

Attributes and attribute values ​​are not case sensitive.

However, the World Wide Web Consortium recommends lowercase attribute/attribute values ​​in its HTML 4 recommendations.

The new version of (X)HTML requires the use of lowercase attributes.


Next Section
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body bgcolor="red"> <h1 align="center">欢迎学习HTML</h1> <h2 align="center">欢迎学习HTML</h2> <h3 align="center">欢迎学习HTML</h3> <p>这里是第一段内容</p> <p>这是第二段内容</p> <a href="http://php.cn/">点击学习</a><br/> <img src="https://img.php.cn/upload/course/000/000/007/57fb2bca70c24537.jpg"> </body> </html>
submitReset Code
ChapterCourseware