HTML & CSS Cheat Sheet

The basics you'll use every day

📄 HTML Essentials

Page Structure
Every HTML page needs this skeleton:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Page Title</title>
</head>
<body>
  <!-- Your content goes here -->
</body>
</html>
Headings
h1 is biggest, h6 is smallest. Use h1 once per page.
<h1>Main Title</h1>
<h2>Section Title</h2>
<h3>Subsection</h3>
Text
<p>Paragraph text</p>
<strong>Bold text</strong>
<em>Italic text</em>
<br> <!-- Line break -->
Links
<a href="https://example.com">Click here</a>
<a href="page.html">Internal link</a>
<a href="#section">Jump to section</a>
Images
<img src="photo.jpg" alt="Description of image">
Lists
<!-- Bullet list -->
<ul>
  <li>Item one</li>
  <li>Item two</li>
</ul>

<!-- Numbered list -->
<ol>
  <li>First</li>
  <li>Second</li>
</ol>
Divs & Spans
Containers for styling. Div = block, Span = inline.
<div class="container">Block container</div>
<span class="highlight">Inline text</span>

🎨 CSS Essentials

Adding CSS
Put this in your <head> section:
<style>
  /* Your CSS here */
</style>
Selectors
/* By tag */
p { color: white; }

/* By class */
.my-class { color: white; }

/* By ID */
#my-id { color: white; }
Colors
color: white; /* Text color */
background: #0a0a0a; /* Hex code */
background: rgb(10,10,10); /* RGB */
Text Styling
font-size: 16px;
font-weight: bold; /* or 400, 600, etc */
text-align: center;
line-height: 1.6;
Spacing
Margin = outside, Padding = inside
margin: 20px; /* All sides */
margin-top: 10px; /* Just top */
padding: 10px 20px; /* Top/bottom, left/right */
Borders
border: 1px solid #222;
border-radius: 8px; /* Rounded corners */
Size
width: 100%;
max-width: 900px;
height: auto;
💡 Pro tip: Use browser DevTools (F12) to inspect any website and see exactly how it's styled. Best way to learn.