Free Ebook cover Complete HTML Course

Complete HTML Course

4.38

(8)

37 pages

HTML best practices

Capítulo 27

Estimated reading time: 3 minutes

+ Exercise
Audio Icon

Listen in audio

0:00 / 0:00

HTML Best Practices

HTML is a markup language used to build web pages. It is essential that the pages created are accessible, readable and easy to maintain. For this, it is important to follow some best practices in HTML.

Use the correct semantic structure

One of the main best practices in HTML is to use the correct semantic structure. This means that each element must be used according to its semantic function. For example, the <h1> element should be used for main headings, while the <p> element should be used for paragraphs.

In addition, it is important to use semantic elements to indicate the structure of the document, such as the <header> element for the page header, the <nav> element for navigation, the <main> element for the main content, and the <footer> element for the footer.

Use alt attributes on images

Images are important to make the page visually appealing, but it's important to remember that not all users have visual access. Therefore, it is essential to use the alt attribute in all images. This attribute describes the image for users who use screen readers or who have vision problems.

Also, it's important to use the title attribute to provide additional information about the image when the user hovers over it.

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

Use descriptive links

Links are critical to web navigation, but it's important to use them descriptively. Instead of using links like "click here", it is better to use links that describe the content to which the user will be directed. For example, instead of "click here to read more", it is better to use "read more about subject X".

Use code validation

One of the best practices in HTML is to use code validation to ensure that the page conforms to language standards. There are several online tools that allow you to validate HTML code, such as the W3C Validator. This helps identify errors and issues on the page, ensuring that the page is accessible and readable for all users.

Use CSS for visual formatting

HTML should be used for structuring the content, while visual formatting should be done with CSS. This helps to separate the content from the visual presentation, making the page easier to maintain and update. In addition, using CSS allows the page to be faster, since the HTML code is lighter and the CSS can be stored in a separate file and cached by the browser.

Conclusion

Following HTML best practices is critical to creating accessible, readable, and maintainable web pages. Use correct semantic structure, use alt attributes on images, use descriptive links, use code validation, and use CSS for visual formatting. With these practices, you will be creating quality web pages that are accessible to all users.

Now answer the exercise about the content:

_What is one of the HTML best practices mentioned in the text?

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

You missed! Try again.

The text emphasizes the importance of using the correct semantic structure as one of the main best practices in HTML. Semantic elements like <header>, <nav>, <main>, and <footer> help in indicating the structure of the document, ensuring accessibility and maintainability.

Next chapter

HTML development tools

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