1. HTML Foundation & Accessibility
HTML: The Skeleton of the Web
HTML (HyperText Markup Language) is the foundation of everything you see on the internet. It does not handle styling or logic; its sole purpose is to provide structure and meaning to content. In this extensive guide, we will break down every core HTML concept individually so you understand exactly how to build web pages from scratch.
Anatomy of an HTML Tag
Almost all HTML elements consist of three parts: an opening tag, the content, and a closing tag. The tags tell the browser how to interpret the content inside.
The HTML Boilerplate
Every HTML document must follow a specific structure to be recognized by web browsers. This is called the boilerplate.
Text Formatting: Headings
Headings range from <h1> to <h6>. You should only ever have one <h1> per page for SEO and accessibility purposes. Use them in sequential order (don't jump from h1 to h4).
Text Formatting: Paragraphs
The <p> tag is used for standard blocks of text. Browsers automatically add some space (margin) above and below paragraphs.
Links (Anchor Tags)
The <a> tag creates hyperlinks to other pages or websites. It requires the href attribute to know where to navigate.
Images
The <img> tag is self-closing. It requires a src (source) attribute to find the image file, and an alt (alternative text) attribute for accessibility.
Semantic Layout: The Header and Footer
Instead of using generic <div> tags, we use semantic tags. Semantic means 'relating to meaning'. <header> represents introductory content or a set of navigational links. <footer> represents the bottom of a section or page.
Semantic Layout: Main, Section, and Article
Structuring your core content properly helps search engines and screen readers understand your page.
Forms: The Form Wrapper
The <form> tag wraps all user inputs. It handles the submission of data to a server.
Forms: Labels and Inputs
Every input must be paired with a label. This is non-negotiable for accessibility. We link them using the for attribute on the label, and the id attribute on the input.
Forms: Buttons
Buttons trigger actions. Inside a form, a button will automatically submit the form unless told otherwise.
Knowledge Check
Ready to test your understanding of 1. HTML Foundation & Accessibility?