Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

Attributes

In the lesson on basic HTML tags, we learned how to create the text content of a web page. In this lesson, we will look at more advanced elements. Before we can use them, though, we need to learn another HTML concept: attributes.

Attributes give an HTML element extra information. We write them in the opening tag of the element, like this:

The code <h1 id="title">Hello world!</h1>, where id="title" is the attribute, id its name and title its value

In the image, you can see an attribute named id with the value title. First comes the name, then an equals sign and then the value in quotes. We always write the value in quotes: we will use double quotes, but single quotes work too.

The id attribute has several uses. For now, it is enough to know that it gives an element a name by which we can find it. That is why every id must be unique: no two elements on the same page can have the same id.

There is also an attribute that every page should have, although we haven't met it yet: lang on the html element. It tells browsers, search engines and screen readers which language the page is written in:

<html lang="en">

In our exercises, it is in the hidden part of the page, together with the document declaration and the head element.

Instructions

  1. 1

    Add an attribute named id with the value title to the h1 element with the content Domestic Cat.

Back

1/14

  1. 1. Attributes
  2. 2. Links
  3. 3. Quiz: Links
  4. 4. Opening Links in a New Tab
  5. 5. Relative Links
  6. 6. Images
  7. 7. Quiz: Images
  8. 8. Image Accessibility
  9. 9. Videos
  10. 10. Images as Links
  11. 11. In-Page Links
  12. 12. Page Structure
  13. 13. Main Content and Sections
  14. 14. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.