HTML attributes

HTML tags can have attributes. Attributes provide more information about HTML elements.

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

Attributes are always specified in the opening tag of an HTML element.


Example

HTML links are defined by the tag. The link's address is specified in the href attribute:

This is a link

    php.cn 
This is a link

Code running result:

1.png

Example explanation: By clicking "This is a link" above, you will jump tohttp:// www.w3school.com.cnThis website



##Attribute example 1:

Defines the beginning of the title.

    php.cn 

标题

Explanation: Center the

title title


##Attribute example 2:< body> defines the body of the HTML document.

    php.cn 

Explanation: The above code means to set the background color of the web page to yellow


Tips

:Attributes and attribute values are not case sensitive sensitive. Newer versions of (X)HTML require lowercase attributes.


Always enclose attribute values in quotesAttribute values should always be enclosed in quotes. Double quotes are the most commonly used, but there is no problem using single quotes.

In some individual cases, such as the attribute value itself contains double quotes, you must use single quotes, for example:

name='Bill "HelloWorld " Gates'


HTML Properties Reference Manual
Our complete HTML Reference Manual A complete list of legal attributes available for each HTML element is provided:

Complete HTML Reference Manual

Attributes that apply to most HTML elements are listed below:

## class classname Specifies the class name of the element id id Specifies the unique id of the element style style_definition Specifies the inline style of the element title text Specifies additional information for the element (can be found in the tooltip Display)
Attribute Value Description
For more information about standard properties, please visit:

HTML Standard Properties Reference Manual


Continuing Learning
||
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!