Artboard 2

Build the internet on DigitalOcean with ☁️ Servers, Managed DBs, K8s. 💰 Start free with a $100 credit.

Attributes

Attributes give extra info to html elements.

Attributes give extra info to html elements.

  • Every element can have attributes
  • Attributes gives additional details about an element
  • Attributes are written in the start tag always
  • Attributes have name-value pairs like name=value

href attribute

Links in html are specified with the <a> element. The link address is defined in the href attribute:

<a href="https://devhoot.ooo" title="DevHoot">This is a link</a>
Href Devhoot

src attribute

Images in html are specified with the <img> element. The image address is defined in the src attribute:

<img src="smiley.jpg" />
src Devhoot

width height attribute

We can specify the width and height of the image with the height & width attributes.

<img src="smiley.jpg" height="200px" width="300px" />
src Devhoot

alt attribute

We can also specify text which will be displayed when an image cannot be displayed.

<img src="cry.jpg" alt="cry" />
alt Devhoot