HTML Attributes

HTML attributes are used to define additional characteristics of HTML elements. They are added to elements using name/value syntax, where name is the attribute name and value is the attribute value.

There are many different HTML attributes that can be used for different HTML elements. Some of the most common attributes include:

  • class: defines the element's class
  • id: defines the ID of the element
  • style: defines the style of the element
  • title: defines the title of the element
  • href: defines the destination URL of the link
  • src: defines the image source file path
  • alt: sets the alt text for the image
  • width: defines the width of the element
  • height: sets the height of the element

HTML attributes can be added to any HTML element. For example, if we want to add a class to a paragraph element, we can use the class attribute:

  <p class="featured">This is a featured paragraph.</p>

In this example, we added the "highlight" class to the paragraph element. This means that we can style this element using CSS by adding styles to the "highlight" class.

In addition, HTML attributes can be used to provide additional information to users. For example, the alt attribute can be used to provide alternative text for an image, which is displayed if the image fails to load or if the user is using a screen reader.

In summary, HTML attributes are an important part of building web pages. They allow developers to add additional information to HTML elements, which can be used to style elements or provide additional information to users.

Now answer the exercise about the content:

_Which HTML attribute is used to define the alt text for an image?

You are right! Congratulations, now go to the next page

You missed! Try again.

Article image Formatting Text with HTML

Next page of the Free Ebook:

5Formatting Text with HTML

2 minutes

Obtenez votre certificat pour ce cours gratuitement ! en téléchargeant lapplication Cursa et en lisant lebook qui sy trouve. Disponible sur Google Play ou App Store !

Get it on Google Play Get it on App Store

+ 6.5 million
students

Free and Valid
Certificate with QR Code

48 thousand free
exercises

4.8/5 rating in
app stores

Free courses in
video, audio and text