BlogCheatsheetHTML Cheatsheet
blog-image
Cheatsheet
Popular
#Cheatsheet
#HTML

HTML Cheatsheet

A beginner-friendly guide to the most commonly used HTML elements and concepts.

IN
Imtiyaz Nandasaniya
@code.clash
12

๐Ÿ Basic Structure

<!DOCTYPE html>
<html>
  <head>
    <title>Page Title</title>
  </head>
  <body>
    <h1>Hello, world!</h1>
  </body>
</html>

๐Ÿงฑ Text Elements

<h1> to <h6>                     # Headings
<p>Paragraph</p>
<strong>Bold</strong>
<em>Italic</em>
<br>                             # Line break
<hr>                             # Horizontal line
<pre>Preformatted text</pre>
<code>Inline code</code>
<blockquote>Quoted text</blockquote>

๐Ÿ”ง Common Attributes

These can be used on most HTML elements:

class="classname"     # For styling with CSS
id="uniqueId"         # For targeting with CSS/JS
style="color: red;"   # Inline styling
title="Tooltip text"  # Shows on hover
hidden                # Hides the element

<!-- Link Attributes -->
<a href="https://example.com" target="_blank" rel="noopener noreferrer">Visit Site</a>  <!-- Opens in new tab safely -->
 
<!-- Image Attributes -->
<img src="image.jpg" alt="Description" width="200" height="150" title="Hover text">

๐Ÿ“ฆ Lists

<!-- Unordered List -->
<ul>
  <li>Item 1</li>
  <li>Item 2</li>
</ul>
 
<!-- Ordered List -->
<ol>
  <li>First</li>
  <li>Second</li>
</ol>
 
<!-- Description List -->
<dl>
  <dt>HTML</dt>
  <dd>HyperText Markup Language</dd>
</dl>

๐Ÿ“ Tables

<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Age</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Ali</td>
      <td>25</td>
    </tr>
  </tbody>
</table>

๐Ÿ“ค Forms

<form action="/submit" method="POST">
  <label for="name">Name:</label>
  <input type="text" id="name" name="name" placeholder="Enter your name" required maxlength="50">
 
  <label for="email">Email:</label>
  <input type="email" id="email" name="email">
 
  <label for="message">Message:</label>
  <textarea id="message" name="message" rows="4" cols="50"></textarea>
 
  <label for="gender">Gender:</label>
  <select id="gender" name="gender">
    <option value="male">Male</option>
    <option value="female">Female</option>
    <option value="other">Other</option>
  </select>
 
  <input type="submit" value="Submit">
</form>

๐Ÿท๏ธ Common Input Attributes

placeholder="text"    # Shows hint text inside the input
required              # Makes input mandatory
maxlength="number"    # Sets maximum number of characters
value="default"       # Sets default value
disabled              # Makes input uneditable
readonly              # Cannot edit but value is visible
checked               # For checkboxes and radio buttons
selected              # For preselecting options in <select>

๐Ÿงฉ Input Types

<input type="text">
<input type="email">
<input type="password">
<input type="checkbox">
<input type="radio">
<input type="date">
<input type="file">
<input type="number">
<input type="range">
<input type="search">
<input type="tel">
<input type="url">

๐ŸŽจ Semantic Tags

<header>
<nav>
<main>
<section>
<article>
<aside>
<footer>
<figure>
<figcaption>
<details>
<summary>

โš™๏ธ Other Useful Tags

<div>         # Generic container
<span>        # Inline container
<iframe>      # Embed another page
<video>       # Embed video
<audio>       # Embed audio
<canvas>      # For drawing graphics
<progress>    # Progress bar
<meter>       # Gauge indicator
<noscript>    # Fallback for no JS
<template>    # Hidden template content

๐Ÿ“Œ Best Practices

  • Always use semantic tags for clarity.
  • Add alt to images for accessibility.
  • Use lowercase for tag names.
  • Nest elements properly.
  • Validate your HTML code.
  • Use label with form inputs for accessibility.
  • Avoid inline styles; use CSS instead.

TIP

Start small. Build simple pages first, then explore forms, multimedia, and advanced layouts.

IN

Imtiyaz Nandasaniya

@code.clash

I&apos;m a passionate content creator and full-stack developer who loves sharing knowledge with the developer community. Through my Instagram @code.clash, I create daily content about programming, web development, and tech insights.

0K+
Followers
0
Posts

Comments

0

Leave a Comment