DEV Community

CodeWithDhanian
CodeWithDhanian

Posted on

6 1 1 1 1

Master HTML in 2 min.

Ready to learn HTML quickly and effectively? This guide covers everything you need—from structure to semantics—with code snippets and explanations for every tag.

Want the full beginner-to-pro HTML, CSS & JavaScript ebook?

Grab it here: codewithdhanian.gumroad.com/l/ydhfb


1. Basic HTML Structure

This is the boilerplate code to start any HTML document.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>My First Page</title>
</head>
<body>
  <h1>Welcome to My Website</h1>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

2. Head Elements

Used to include metadata, styles, and scripts.

<head>
  <title>Portfolio</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="styles.css">
  <style>
    body { font-family: Arial, sans-serif; }
  </style>
  <script src="app.js" defer></script>
</head>
Enter fullscreen mode Exit fullscreen mode

3. Text Formatting Tags

<h1>Main Heading</h1>
<p>This is a <strong>bold</strong> and <em>italic</em> sentence.</p>
<mark>Highlighted text</mark>
<small>Smaller font</small>
<blockquote>"This is a quoted text."</blockquote>
<hr>
<br>
Enter fullscreen mode Exit fullscreen mode

4. Lists: Ordered, Unordered & Description

<ul>
  <li>HTML</li>
  <li>CSS</li>
</ul>

<ol>
  <li>First</li>
  <li>Second</li>
</ol>

<dl>
  <dt>HTML</dt>
  <dd>HyperText Markup Language</dd>
</dl>
Enter fullscreen mode Exit fullscreen mode

5. Links and Anchor Tags

<a href="https://google.com" target="_blank">Open Google</a>
<a href="resume.pdf" download>Download Resume</a>
<a href="mailto:you@example.com">Email Me</a>
Enter fullscreen mode Exit fullscreen mode

6. Images with Attributes

<img src="photo.jpg" alt="A scenic view" width="400" loading="lazy">
Enter fullscreen mode Exit fullscreen mode

7. Tables: Structuring Data

<table border="1">
  <thead>
    <tr><th>Product</th><th>Price</th></tr>
  </thead>
  <tbody>
    <tr><td>Pen</td><td>$1</td></tr>
    <tr><td>Notebook</td><td>$2</td></tr>
  </tbody>
</table>
Enter fullscreen mode Exit fullscreen mode

8. Forms: Collecting Input

<form action="/submit" method="POST">
  <label for="name">Name:</label>
  <input type="text" id="name" name="name" placeholder="Your Name" required>

  <label for="msg">Message:</label>
  <textarea id="msg" name="message" rows="4"></textarea>

  <label for="gender">Gender:</label>
  <select id="gender" name="gender">
    <option value="male">Male</option>
    <option value="female">Female</option>
  </select>

  <button type="submit">Submit</button>
</form>
Enter fullscreen mode Exit fullscreen mode

9. Embedding Media

<video width="320" height="240" controls>
  <source src="video.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video>

<audio controls>
  <source src="sound.mp3" type="audio/mpeg">
</audio>
Enter fullscreen mode Exit fullscreen mode

10. Semantic HTML Tags

<header>
  <h1>My Blog</h1>
</header>

<nav>
  <a href="/">Home</a>
  <a href="/about">About</a>
</nav>

<main>
  <section>
    <article>
      <h2>Article Title</h2>
      <p>This is a blog post.</p>
    </article>
  </section>
</main>

<footer>
  <p>&copy; 2025 My Blog</p>
</footer>
Enter fullscreen mode Exit fullscreen mode

11. Inline vs Block Elements

  • Block elements start on a new line.
<div>This is a block-level element.</div>
<p>Paragraph is also block-level.</p>
Enter fullscreen mode Exit fullscreen mode
  • Inline elements do not start on a new line.
<span>This is inline</span>
<a href="#">Link is also inline</a>
Enter fullscreen mode Exit fullscreen mode

12. Global Attributes

<div id="main" class="container" data-user="123" hidden lang="en" style="color:blue;"></div>
Enter fullscreen mode Exit fullscreen mode

13. Deprecated Tags (Avoid These!)

<!-- These are outdated and should NOT be used -->
<center>Centered Text</center>
<font color="blue">Old Way of Styling</font>
<bgsound src="music.mid"> <!-- Deprecated -->
Enter fullscreen mode Exit fullscreen mode

14. Accessibility & SEO Tips

  • Use <alt> on images:
<img src="logo.png" alt="Company Logo">
Enter fullscreen mode Exit fullscreen mode
  • Use headings logically:
<h1>Main Title</h1>
<h2>Section Title</h2>
<h3>Subsection</h3>
Enter fullscreen mode Exit fullscreen mode
  • Use ARIA roles if needed:
<nav role="navigation">...</nav>
Enter fullscreen mode Exit fullscreen mode

BONUS: Get the Full eBook

This article is just the tip of the iceberg.

Unlock your full potential with "HTML, CSS & JavaScript for Web Developers"

Packed with examples, practice projects, and cheat sheets for rapid learning!

Download Now:

codewithdhanian.gumroad.com/l/ydhfb

Tiugo image

Fast, Lean, and Fully Extensible

CKEditor 5 is built for developers who value flexibility and speed. Pick the features that matter, drop the ones that don’t and enjoy a high-performance WYSIWYG that fits into your workflow

Start now

Top comments (1)

Collapse
 
mahdijazini profile image
Mahdi Jazini

Nice 👏

Neon image

Next.js applications: Set up a Neon project in seconds

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Get started →