HTML Attributes

HTML Tutorial

HTML Attributes

HTML attributes provide extra information about an HTML element. They are always written in the start tag and usually come in name=”value” format.


Example


 

  • href is the attribute

  • "https://google.com" is the value


Common Attributes

AttributeUsed WithPurpose
href<a>Defines the link URL
src<img>Defines image file path
alt<img>Provides alternative text
styleAny tagAdds inline CSS styling
idAny tagUnique identifier
classAny tagUsed to group elements

Another Example


Here:

  • src, alt, and width are attributes.


Attributes make elements more meaningful and functional.

You may also like...