Free Ebook cover Complete HTML Course

Complete HTML Course

4.38

(8)

37 pages

HTML Attributes

Capítulo 4

Estimated reading time: 2 minutes

Audio Icon

Listen in audio

0:00 / 0:00

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.

Continue in our app.

You can listen to the audiobook with the screen off, receive a free certificate for this course, and also have access to 5,000 other free online courses.

Or continue reading below...
Download App

Download the app

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.

The alt attribute is used to define alternative text for an image. It is important for accessibility, as it provides a textual description of the image content for users who are visually impaired or when the image fails to load.

Next chapter

Formatting Text with HTML

Arrow Right Icon
Download the app to earn free Certification and listen to the courses in the background, even with the screen off.