HTML Attributes

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

Attribute Used With Purpose
href <a> Defines the link URL
src <img> Defines image file path
alt <img> Provides alternative text
style Any tag Adds inline CSS styling
id Any tag Unique identifier
class Any tag Used to group elements

Another Example


 

Here:

  • src, alt, and width are attributes.


Attributes make elements more meaningful and functional.

You may also like...