How HTML works
HTML (HyperText Markup Language) uses tags to mark up content. Most tags come in pairs: an opening tag and a closing tag with a slash.
<p>This is a paragraph.</p>
The opening tag, the content and the closing tag together form an element. Tags can also have attributes, which give extra information. They are written inside the opening tag as name="value":
<a href="https://www.wikipedia.org">Visit Wikipedia</a>
Some elements have no content and no closing tag, such as <br> (line break) and <img>.
The basic page structure
Every HTML page follows the same skeleton:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Asha Verma | Profile</title>
</head>
<body>
<!-- Everything visible goes here -->
</body>
</html>
<!DOCTYPE html> tells the browser this is a modern HTML document.<html lang="en"> wraps the whole page and states its language, which helps screen readers and search engines.<head> holds information about the page: the character set, the title and, later, links to CSS.- The
viewport meta tag makes the page display properly on phones. <body> holds everything the visitor sees.<!-- ... --> is a comment; the browser ignores it.
Headings and paragraphs
HTML has six heading levels, from <h1> (most important) to <h6>. Use one <h1> per page for the main title, then <h2> for sections and <h3> for sub-sections. Do not choose headings just for their size; size can be changed with CSS. Search engines and screen readers use headings to understand the page.
<h1>Asha Verma</h1>
<p>I am a <strong>commerce student</strong> from Indore learning <em>web development</em>.</p>
<h2>Skills</h2>
<strong> marks important text (shown bold) and <em> marks emphasis (shown in italics).
Lists
Use an unordered list <ul> for bullet points and an ordered list <ol> for numbered steps. Each item goes inside <li>.
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
<ol>
<li>Plan the page</li>
<li>Write the HTML</li>
<li>Add styles</li>
</ol>
Links
The <a> (anchor) tag creates links. The href attribute holds the destination.
<a href="about.html">About me</a>
<a href="https://github.com" target="_blank" rel="noopener">My GitHub</a>
<a href="mailto:asha@example.com">Email me</a>
<a href="#contact">Jump to contact section</a>
about.html is a relative link to another file in the same folder.target="_blank" opens the link in a new tab; add rel="noopener" for safety.#contact jumps to the element with id="contact" on the same page.
Semantic layout tags
Semantic tags describe the meaning of each part of the page. They make your code easier to read and help accessibility and SEO.
<body>
<header>
<h1>Asha Verma</h1>
<nav>
<a href="#about">About</a>
<a href="#skills">Skills</a>
<a href="#contact">Contact</a>
</nav>
</header>
<main>
<section id="about">
<h2>About me</h2>
<p>I enjoy building simple, useful websites.</p>
</section>
<section id="skills">
<h2>Skills</h2>
<ul>
<li>HTML</li>
<li>CSS</li>
</ul>
</section>
</main>
<footer>
<p id="contact">Contact: asha@example.com</p>
</footer>
</body>
| Tag | Use it for |
|---|
header | The top area: logo, site name, navigation |
nav | A group of main navigation links |
main | The main content (one per page) |
section | A themed group of content with a heading |
article | Self-contained content, such as a blog post |
footer | The bottom area: contact details, copyright |
Common mistakes
- Forgetting to close tags, or closing them in the wrong order. Close the most recently opened tag first.
- Using
<br> repeatedly for spacing instead of paragraphs and CSS. - Skipping heading levels or using several
<h1> tags.
Practice task
- Create
profile.html using the page skeleton. - Add a
header with your name in an <h1> and a nav with three links to sections on the page. - Inside
main, add three sections: About me, Skills (an unordered list) and Goals (an ordered list). - Add a
footer with an email link using mailto:. - Open the page and check that each navigation link jumps to the right section.