HTML Attributes

 

Attributes 

HTML attributes are properties of tags that provide additional information about HTML elements. We can use them to modify the behaviour of HTML elements.


Key points of HTML Attributes:

There are several important points about HTML attributes you should keep in mind while working with attributes.


(1) We can put attributes after the element name in the opening tag only, never in the closing tag.

(2) As per need, we can apply several attributes to an element, separated by spaces in the opening tag. Their order is not important.

(3) Most HTML attributes take values, which follow an equal sign (=). Some attribute values take a single descriptive word.

(4) HTML allows us to enclose attribute values either in single or double quotation marks. Both are acceptable as long as the opening and closing marks match. Note that quotation marks in HTML files must be straight (“), not curly (”).


Types of HTML Attributes

There are mainly three types of HTML attributes. They are as:

(1) Global attributes: We can use these attributes with any HTML element. They provide a general-purpose way to add additional information to an element. Some commonly used global attributes are class, id, style, and title.


(2) Event attributes: We use these attributes to define how an element responds to user actions, such as clicks or mouse movements. Some commonly used event attributes are onclick, onmouseover, and onmouseout.


(3) Element-specific attributes: These attributes are unique for specific HTML elements that provide additional customization options for elements. For example, we use the src attribute to specify the URL of an image in the img element. Some commonly used element-specific attributes are src, href, and type.


Comments

Popular posts from this blog

HTML tags

Introduction of HTML