HTML5 CSS3

CHEAT SHEET

Quick Reference Guide for HTML Essentials & Core CSS Properties

🌐 Part 1: HTML Essentials

1. Document Structure
ElementDescription
<!DOCTYPE html>Declares HTML5 document type
<html>Root element of an HTML page
<head>Contains metadata & page info
<title>Sets page title in browser tab
<body>Contains visible content
<meta>Viewport, charset & SEO tags
<link>Links external CSS or favicons
<script>Embeds or links JavaScript
Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Page</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <h1>Hello, World!</h1>
</body>
</html>
2. Text & Content
ElementDescriptionExample
<h1> - <h6>Headings (h1 highest)<h1>Heading</h1>
<p>Paragraph block<p>Text</p>
<a>Hyperlink<a href="...">Link</a>
<img>Image tag<img src="x.jpg" alt="pic">
<br> / <hr>Line break / Horizontal rule<br> / <hr>
<strong>Important text (bold)<strong>Bold</strong>
<em>Emphasized text (italic)<em>Italic</em>
<span> / <div>Inline / Block container<div class="box">
Example
<h1>Welcome</h1>
<p>This is <strong>bold</strong> and <em>italic</em> text.</p>
<a href="https://example.com" target="_blank">Visit Example</a>
<img src="image.jpg" alt="Sample Image" width="200">
<div class="box">This is a div container.</div>
3. Lists
ElementDescriptionExample
<ul>Unordered list (bullets)<ul>...</ul>
<ol>Ordered list (numbers)<ol>...</ol>
<li>List item entry<li>Item</li>
Example
<!-- Unordered List -->
<ul>
  <li>Apple</li>
  <li>Banana</li>
  <li>Cherry</li>
</ul>

<!-- Ordered List -->
<ol>
  <li>First</li>
  <li>Second</li>
</ol>
4. Tables
ElementDescription
<table>Table container
<tr>Table row
<th>Table header cell (bold/centered)
<td>Table data cell
<caption>Table caption / title
Example
<table border="1">
  <caption>Student Info</caption>
  <tr>
    <th>Name</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Alice</td>
    <td>20</td>
  </tr>
</table>
5. Forms
ElementDescriptionExample
<form>Form container<form action="#">
<input>User input control<input type="text">
<label>Label for form element<label for="name">
<select> / <option>Drop-down list<option value="1">
<textarea>Multi-line input<textarea rows="4">
<button>Clickable button<button type="submit">
Example
<form action="/submit" method="post">
  <label for="name">Name:</label>
  <input type="text" id="name" required><br>

  <select name="country">
    <option value="mm">Myanmar</option>
    <option value="us">USA</option>
  </select><br>

  <button type="submit">Submit</button>
</form>
6. Semantic Elements (HTML5)
ElementDescription
<header>Top banner / introductory content
<nav>Navigation menu links
<main>Central content of the document
<section>Thematic section of content
<article>Independent, self-contained post
<aside>Sidebar or supplementary info
<footer>Footer info, copyright, contact
Example
<header><h1>Header</h1></header>
<nav><a href="#">Home</a></nav>
<main>
  <section>Main Article Content</section>
  <aside>Related Links</aside>
</main>
<footer>Footer Info</footer>
7. Commonly Used Attributes
AttributeDescription
idUnique identifier for single element
classReusable class names for styling
styleInline CSS definitions
hrefLink URL destination
srcPath to media resource (img, script)
altAlternative text for screen readers
targetWhere to open link (e.g. _blank)
Example
<a href="https://example.com" target="_blank" title="Visit Example">
  Example Link
</a>

<div id="main" class="container" style="color: blue;">
  Content
</div>
8. Comments & Quick Tips
HTML Comment Syntax
<!-- This is a comment -->
<p>This text is visible.</p>
<!-- Another comment -->
Quick Tips
  • Always close tags cleanly and properly.
  • Use semantic HTML tags for better SEO & accessibility.
  • Validate markup using the official W3C Validator.
  • Keep structure (HTML) and presentation (CSS) separated.

🎨 Part 2: CSS Basics & Properties

CSS Box Model
Margin
Border
Padding
Content
.box {
  margin: 20px;       /* Outer spacing */
  border: 2px solid;  /* Outline border */
  padding: 15px;      /* Inner spacing */
  width: 200px;       /* Content size */
}
Fonts and Text
PropertyValues / Syntax
font-familyArial, sans-serif, monospace
font-size16px, 1.2rem, 100%
letter-spacing1px, 2px, -0.5px
line-height1.5, 24px, normal
font-weightbold, normal, 600, 700
font-styleitalic, normal, oblique
text-decorationunderline, line-through, none
text-alignleft, right, center, justify
text-transformcapitalize, uppercase, lowercase
Positioning & Layout
PropertyCommon Values
positionstatic, relative, absolute, fixed, sticky
displayblock, inline, inline-block, flex, grid, none
top / right / bottom / left0, 10px, 50%, auto
z-index1, 10, 999, auto
float / clearleft, right, both, none
overflowvisible, hidden, scroll, auto
visibilityvisible, hidden, collapse
CSS Color Formats

CSS accepts color values in multiple notations:

/* Color Name */
color: red;

/* Hexadecimal */
color: #ff0000;
background-color: #f1f5f9;

/* RGB & RGBA (with opacity) */
color: rgb(255, 0, 0);
background-color: rgba(0, 0, 0, 0.5);

/* HSL */
color: hsl(0, 100%, 50%);