1. Introduction to HTML
Introduction to HTML
HTML (HyperText Markup Language) is the standard markup language for creating web pages. It describes the structure of a webpage β not how it looks (that's CSS), not how it behaves (that's JavaScript) β just the content and its meaning.
HTML uses elements (also called tags) to tell the browser what everything is. Think of HTML as the skeleton of a website.
Your First HTML Page
Every HTML document starts with a DOCTYPE declaration, followed by an <html> tag that wraps everything, containing a <head> (for metadata) and a <body> (for visible content).
HTML Elements and Tags
Most HTML elements have an opening tag and a closing tag with a slash. Content goes between them.
- <h1> to <h6> β Headings (largest to smallest)
- <p> β Paragraph
- <br> β Line break (self-closing, no closing tag)
- <hr> β Horizontal rule (thematic break)
Text Formatting Tags
HTML provides tags to give text semantic meaning (not just visual style). Screen readers and search engines use these to understand importance.
Links - The Anchor Tag
The <a> (anchor) tag creates hyperlinks. The href attribute specifies the destination URL. Without href, it's just a placeholder.
The target="_blank" attribute makes the link open in a new browser tab. Always use this for external links so users don't navigate away from your site.
Images - The Img Tag
The <img> tag embeds images. It is self-closing (no closing tag) and requires two attributes: src (image source URL) and alt (alternative text for accessibility).
The alt attribute is critical for accessibility β screen readers read it aloud to visually impaired users. It also displays if the image fails to load.
Lists in HTML
HTML has three types of lists. Each serves a different purpose.
Lists can be nested β put a list inside another list item to create sub-lists.
Knowledge Check
Ready to test your understanding of 1. Introduction to HTML?