Attribute Best Practices in HTML
📖 Scenario: You are creating a simple webpage for a local bakery. The page will have a header, a navigation menu, a main section with a welcome message, and a footer. You want to make sure the HTML uses attributes correctly for accessibility and clarity.
🎯 Goal: Build a basic HTML5 page structure with semantic elements and add appropriate attributes such as lang, charset, viewport, aria-label, and alt to improve accessibility and proper rendering.
📋 What You'll Learn
Use the
lang attribute on the <html> tag with value enAdd a
<meta> tag with charset set to UTF-8Add a
<meta> tag with name set to viewport and content set to width=device-width, initial-scale=1.0Add an
aria-label attribute to the <nav> element describing it as 'Primary navigation'Add an
alt attribute to the bakery logo image describing it as 'Bakery logo'💡 Why This Matters
🌍 Real World
Webpages need proper attributes to be accessible to all users, including those using screen readers or mobile devices.
💼 Career
Knowing how to use HTML attributes correctly is essential for front-end developers to build inclusive and well-functioning websites.
Progress0 / 4 steps