From Absolute Beginner to Advanced Developer
**HTML (HyperText Markup Language)** is the standard markup language for creating web pages. It describes the structure and content of a webpage using a system of tags and elements.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First Web Page</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is my first paragraph.</p>
</body>
</html>
An **element** consists of a start tag, content, and an end tag.
// Element Structure: <tagname>Content goes here</tagname> // Self-Closing Tags (No content, no closing tag): <br> <!-- Line break --> <hr> <!-- Horizontal rule --> <img src="photo.jpg" alt="Description"> <input type="text">
Attributes provide extra information about an element and are always placed inside the start tag.
<element attribute="value">Content</element>
Common attributes: id (unique identifier), class (group identifier for styling), href (link destination), src (source for images/media), alt (alternative text).
Semantic elements clearly describe their meaning to both browser (for accessibility and SEO) and developer. Below is a standard page structure:
<header>...</header>
<nav>...</nav>
<main>
<article>
<h2>Article Title</h2>
<p>Article content...</p>
</article>
<section>...</section>
<aside>...</aside>
</main>
<footer>...</footer>
| Type | Characteristics | Examples |
|---|---|---|
| **Block** | Takes up full width, starts on a new line, holds other blocks. | <div>, <p>, <h1>-<h6>, <form> |
| **Inline** | Takes only necessary width, stays on same line, holds only inline elements. | <span>, <a>, <strong>, <input>, <code> |
<div>This is a block element</div> <div>This starts on a new line</div> <span>This is inline</span> <span>and stays on same line</span>
Headings define structure and hierarchy. Use them correctly for accessibility and SEO, not just for text size.
<h1>Main Heading</h1> <h2>Sub Heading</h2> <h3>Section Heading</h3> // ... down to h6
Prefer **semantic tags** (e.g., <strong>) over presentational tags (e.g., <b>) as they convey meaning.
| Tag | Purpose (Semantic) | Visual Result |
|---|---|---|
<strong> |
Importance (SEO, Screen Readers) | **Bold** |
<em> |
Emphasis (Altered Meaning) | *Italic* |
<code> |
Computer Code Snippet | Code Font |
<mark> |
Highlighting/Relevance | Highlighted |
The <a> tag creates hyperlinks, using the href attribute for the destination.
// External Link (Opens in new tab) <a href="https://google.com" target="_blank" rel="noopener noreferrer">Google</a> // Internal Link (Same page jump) <a href="#section1">Jump to Section 1</a> // Email Link <a href="mailto:email@example.com">Send Email</a>
The <img> tag is self-closing and uses the src attribute for the image file path.
<img src="photo.jpg"
alt="Description of image (Required!)"
width="300"
loading="lazy">
// Basic Video Embed
<video width="640" controls>
<source src="video.mp4" type="video/mp4">
</video>
// Embed YouTube video (Iframe)
<iframe width="560" height="315"
src="https://www.youtube.com/embed/..."
frameborder="0"
allowfullscreen>
</iframe>
<form action="/submit" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<button type="submit">Submit</button>
</form>
action is the URL where data is sent. method is usually POST for data submission.
// Password Input with minimum length validation <input type="password" minlength="8" required> // Date Picker <input type="date" name="birthday"> // File Upload (accepting images only) <input type="file" name="photo" accept="image/*"> // Read-only field <input type="text" value="Cannot change" readonly>
Tables must be used for **tabular data** (like spreadsheets), not for page layout.
<table>
<caption>Monthly Sales Report</caption>
<thead>
<tr> <th>Month</th> <th>Sales</th> </tr>
</thead>
<tbody>
<tr> <td>January</td> <td>$50,000</td> </tr>
</tbody>
<tfoot> <!-- Used for totals/summary -->
<tr> <th>Total</th> <td>$110,000</td> </tr>
</tfoot>
</table>
<th colspan="2">Name (Spans 2 columns)</th> <td rowspan="2">Age (Spans 2 rows)</td>
**CSS (Cascading Style Sheets)** controls the visual presentation of HTML elements. It defines colors, fonts, layouts, and spacing.
<link rel="stylesheet" href="styles.css">
<style>
h1 { color: blue; }
</style>
<p style="color: red; font-size: 18px;">Red text</p>
#header { /* By ID: 100 points */ }
.btn { /* By Class: 10 points */ }
p { /* By Element: 1 point */ }
h1, h2, h3 { /* Grouping */ }
/* Selects all <p> inside any <div> */
div p { color: blue; }
/* Selects only direct <p> children of <div> */
div > p { color: red; }
/* Selects the <p> immediately following an <h1> */
h1 + p { font-weight: bold; }
| Source | Example | Points |
|---|---|---|
| Inline Styles | style="..." |
1000 |
| ID Selector | #idName |
100 |
| Class/Attribute/Pseudo-class | .class, [type="text"], :hover |
10 |
| Element/Pseudo-element | p, ::before |
1 |
Every HTML element is a box composed of four layers: **Content**, **Padding** (inside border), **Border** (Primary Light Green), and **Margin** (outside border).
box-sizing: border-box; on the universal selector (*) to ensure that padding and border are included *inside* the element's defined width.
// Sets 10px on all 4 sides margin: 10px; // Sets 10px Top/Bottom, 20px Left/Right padding: 10px 20px; // Sets Top: 5px, Right: 10px, Bottom: 15px, Left: 20px border-width: 5px 10px 15px 20px;
**Flexbox** is a single-dimension layout model, perfect for distributing space and aligning items along an axis (row or column).
justify-content: Aligns items along the main axis (e.g., space-between, center).
align-items: Aligns items along the cross axis (perpendicular to the main axis).
flex-grow: Specifies how much an item should grow relative to the rest.
**CSS Grid** is a two-dimension layout model, excellent for full page layouts and complex component structures (defining both rows and columns).
grid-template-columns: Defines column structure (e.g., repeat(3, 1fr)).
grid-gap: Sets spacing between grid cells.
grid-area / grid-column / grid-row: Defines element placement.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
This tells the browser to set the viewport width equal to the device width, enabling responsive scaling.
Used to apply styles only when certain conditions (like screen size) are met. Essential for adapting layout between mobile and desktop.
/* Default styles for all devices (Mobile First approach) */
.container { padding: 10px; }
@media (min-width: 768px) {
/* Styles applied ONLY when screen is 768px or wider (Tablet/Desktop) */
.container { max-width: 1200px; padding: 20px; }
}