HTML Attributes

 

HTML Attributes:

Attributes are additional piece of information.

What they are: They’re extra bits of information placed within an HTML element’s opening tag.

How they look: They come in name-value pairs, separated by an equals sign (=).

What they do: They provide additional instructions or details about the element, influencing its behavior, appearance, or accessibility.

Example:

 

<img src=“myimage.jpg” alt=“This is myimage”>

 

In the above example src and alt are attributes of img tag.

Common examples for HTML Attributes:

 

src: Specifies the source of an image or media file.

Example: <img src=”cute_dog.jpg” alt=”my favorite dog”>

href: Defines the destination of a hyperlink.

Example: <a href=”https://www.example.com”>Visit my website</a>

alt: Provides alternative text for images, essential for accessibility and search engines.

Example: <img src=”diagram.png” alt=”Flowchart of the process”>

Join Our Newsletter