Your cart is currently empty!
Learn HTML (Full Tutorial)

HTML Basics
What is HTML?
-
HTML = Hyper Text Markup Language
-
Standard language for creating web pages
-
Describes the structure of a web page using elements
-
Elements label content (e.g., heading, paragraph, link)
A Simple HTML Document
Explained:
-
<!DOCTYPE html>→ defines HTML5 document -
<html>→ root element -
<head>→ meta info -
<title>→ shown in browser tab -
<body>→ visible content -
<h1>→ heading -
<p>→ paragraph
HTML Elements
-
Structure:
<tagname>Content</tagname> -
Example:
<h1>Heading</h1> -
Some elements are empty (no end tag), e.g.,
<br>
Nested Elements: Elements can contain other elements:
Web Browsers
-
Chrome, Edge, Firefox, Safari read HTML and display it correctly
-
Browsers ignore tags and use them to format content
HTML Headings & Paragraphs
Links and Images
Links: <a href="https://example.com">Click here</a>
Images: <img src="img.jpg" alt="Description" width="100" height="150">
-
src→ path to image (absolute or relative URL) -
alt→ alternative text -
width&height→ dimensions
HTML Attributes
-
Extra info for elements, always in start tag
-
Format:
name="value"
Common Attributes:
-
href→ link destination -
src→ image source -
alt→ alternate text for images -
style→ inline styles (color, font, size) -
lang→ language of page (<html lang="en-US">) -
title→ tooltip text
Creating a Web Page with Notepad/TextEdit
-
Open editor: Notepad (Windows) / TextEdit (Mac, Plain Text mode)
-
Write HTML (see example above)
-
Save:
index.html, encoding UTF-8 -
Open in browser: double-click file
HTML Headings & Paragraphs
Headings (<h1> to <h6>)
-
<h1>→ most important,<h6>→ least important -
Browsers add spacing automatically
-
Headings help SEO and readability
-
Use headings for structure, not just for bold/big text
Paragraphs (<p>)
-
Starts on a new line, browser adds spacing automatically
-
Extra spaces/lines in HTML are ignored
Line Breaks (<br>)
-
Forces a new line without starting a new paragraph
Preformatted Text (<pre>)
-
Preserves spaces and line breaks
-
Fixed-width font
Horizontal Rule (<hr>)
-
Defines a thematic break, empty element (no end tag)
HTML Styles (style Attribute)
Syntax: <tag style="property:value;">
Examples:
Common CSS properties:
-
color→ text color -
background-color→ background color -
font-family→ font -
font-size→ text size -
text-align→ alignment
HTML Text Formatting
Bold & Italic
Other formatting
HTML Quotation & Citation Elements
<blockquote> – long quotes (indented by browser)
<q> – short inline quotes (adds quotation marks)
<abbr> – abbreviations with title tooltip
<address> – contact info, usually italicized
<cite> – work titles (books, movies, paintings)
<bdo> – text direction override
HTML Comments
-
Not displayed in browser
-
Syntax:
<!-- Comment here --> -
Can hide content or debug code
HTML Colors
-
Can use names, HEX, RGB, HSL, RGBA, HSLA
-
Border, padding, margin examples:
CSS Basics
CSS = Cascading Style Sheets – controls layout, colors, fonts, spacing, responsive design.
Ways to add CSS:
-
Inline:
<p style="color:red;">Red text</p> -
Internal:
-
External:
Common CSS Properties:
-
color→ text color -
background-color→ background -
font-family→ font -
font-size→ size -
text-align→ alignment -
border→ element border -
padding→ inside spacing -
margin→ outside spacing
HTML Links
Basic link:
Target attribute:
-
_self→ same tab (default) -
_blank→ new tab/window
Relative vs Absolute URLs:
Image as link:
Email link:
Tooltip with title:
HTML Images
<img> – embeds images. Empty tag, must include:
-
src→ image URL/path -
alt→ alternate text if image can’t load
Image Size
-
Using attributes:
width="500" height="600" -
Using CSS:
style="width:500px;height:600px;"(recommended)
Images in folders / external URLs:
Animated GIFs:
Image as a link:
Floating images (left/right):
Common image formats: GIF, PNG, JPG/JPEG, SVG, ICO, APNG
Tips:
-
Always set
width&heightto prevent page flicker -
Large images slow page loading
HTML Image Maps
Clickable areas on an image
Step 1: Add usemap to <img>
Step 2: Define the map with <map> and a name matching usemap
Shapes for <area>:
-
rect→ rectangle,coords="x1,y1,x2,y2" -
circle→ circle,coords="centerX,centerY,radius" -
poly→ polygon,coords="x1,y1,x2,y2,..." -
default→ entire image
Step 3: Optional JavaScript on click
HTML Background Images
Add a background image using CSS:
-
Inline:
-
Internal CSS:
Prevent repeating:
Cover entire element without stretching:
Stretch to fill element:
HTML <picture> Element
Display different images for different devices/screen sizes:
Use cases:
-
Save bandwidth for small devices.
-
Browser format support (choose supported image type).
Always include an <img> fallback as the last child.
HTML Favicon
Add a small icon in the browser tab:
Supported formats: ICO, PNG, GIF, JPEG, SVG (all modern browsers).
Tips: Simple, high-contrast, small image works best.
HTML Tables
Basic Table Structure:
-
<tr>→ table row -
<td>→ table cell -
<th>→ table header (bold & centered by default) -
<caption>→ table caption
Table Borders:
Border styles & color:
Table Size:
-
Table width:
<table style="width:100%"> -
Column width:
<th style="width:70%"> -
Row height:
<tr style="height:200px">
Table Headers:
-
Vertical headers: first
<th>in each row -
Left-align headers:
th { text-align:left; } -
Header spanning multiple columns:
colspan="2"
Example Caption:
HTML Table Padding & Spacing
-
Cell Padding: space between cell content and cell edge.
-
Cell Spacing: space between cells (border-spacing).
HTML Table Styling
-
Horizontal Zebra Stripes:
-
Vertical Zebra Stripes:
-
Combined Zebra (transparent):
-
Horizontal Dividers:
-
Hoverable Table Rows:
HTML Lists
-
Unordered List (
<ul>):
-
Ordered List (
<ol>):
Types: 1 (numbers), A (uppercase letters), a (lowercase letters), I (uppercase Roman), i (lowercase Roman).
-
Description List (
<dl>):
-
Nested Lists: lists inside
<li>items. -
Horizontal List (CSS):
-
List Style Markers (
list-style-type):disc,circle,square,none.
HTML Block and Inline Elements
-
Block-level: starts on new line, full width (
<div>,<p>,<h1>–<h6>,<table>,<section>, etc.) -
Inline: does not start on new line, only as wide as needed (
<span>,<a>,<img>,<strong>,<em>,<input>, etc.) -
Notes: Inline elements cannot contain block-level elements.
-
Example:
HTML Class Attribute
-
Assign a class to elements to style multiple elements the same way.
-
CSS:
-
Multiple Classes:
<div class="city main">→ applies styles from both classes. -
JavaScript Access:
document.getElementsByClassName("city")
HTML id Attribute
-
Unique identifier for a single element.
-
CSS:
#myHeader { background-color: lightblue; } -
JavaScript Access:
document.getElementById("myHeader") -
Bookmarks: link to id:
<a href="#myHeader">Go to Header</a> -
Class vs ID: class = multiple elements, id = unique element.
HTML Iframes
-
Embed a page within a page:
-
Target a link to iframe:
HTML JavaScript
-
Add scripts with
<script>tag:
-
Change styles dynamically:
-
Change attributes:
-
Fallback for browsers without JS:
HTML File Paths
-
Relative Paths: Relative to the current file/folder:
-
Same folder:
<img src="picture.jpg"> -
Subfolder:
<img src="images/picture.jpg"> -
Parent folder:
<img src="../picture.jpg">
-
-
Absolute Paths: Full URL:
-
<img src="https://example.com/images/picture.jpg">
-
HTML <head> Element (#32)
-
Purpose: Contains metadata (not displayed).
-
Common Elements:
-
<title>– Page title (required, important for SEO) -
<style>– Internal CSS -
<link>– External CSS -
<meta>– Charset, description, keywords, author, viewport -
<script>– JavaScript -
<base>– Default URL/target for relative links
-
-
Viewport: Essential for responsive design:
HTML Layout Elements
-
Semantic structure:
-
<header>,<nav>,<section>,<article>,<aside>,<footer>,<details>,<summary>
-
-
Layout techniques:
-
CSS frameworks
-
CSS float, flexbox, grid
-
Responsive Web Design
-
Adjust content for all devices.
-
Techniques:
-
Responsive images (
max-width:100%; height:auto;) -
<picture>element for different images -
Responsive text using
vw -
Media queries for breakpoints
-
Computer Code Elements
-
<kbd>– Keyboard input -
<samp>– Program output -
<code>– Inline code -
<pre>– Preformatted text -
<var>– Variables
Semantic Elements
-
Semantic = meaningful to browser & developer
-
Examples:
<article>,<section>,<header>,<footer>,<nav>,<aside>,<figure>,<figcaption>
HTML Style Guide
-
Always declare
<!DOCTYPE html> -
Use lowercase for tags & attributes
-
Close all elements
-
Quote attribute values
-
Specify
alt,width,heightfor images -
Indent & format for readability
-
Include
<title>and<meta charset>early -
Add
langattribute to<html>
HTML Entities
-
Reserved characters:
-
<→<or< -
>→>or> -
Non-breaking space:
-
-
Diacritics & other special characters can be represented with numeric entities.
HTML Symbols
-
Math symbols, Greek letters, and currency signs:
-
Α→ Α -
©→ © -
€→ €
-
Using Emojis in HTML
-
Emojis are UTF-8 characters, not images.
-
Use numeric entities:
-
Emojis can be resized with CSS (
font-size).
HTML Forms
<form> Element
-
Container for user input elements (text fields, checkboxes, radio buttons, buttons, etc.).
-
Syntax:
<input> Element
-
Most used form element.
-
Types:
| Type | Description |
|————|————-|
| text | Single-line text input |
| radio | Radio button (choose one) |
| checkbox | Checkbox (choose zero or more) |
| submit | Submit button |
| button | Clickable button |
Example – Text Fields
<label> Element
-
Provides accessibility for screen readers.
-
Clicking the label toggles radio/checkbox input.
-
Use
forattribute = inputid.
Radio Buttons
Checkboxes
Submit Button
-
Sends form data to server.
-
Example:
Name Attribute
-
Input must have
nameto submit data; otherwise value is ignored.
HTML Canvas Graphics
-
<canvas>: container for graphics; drawing done via JavaScript. -
Syntax:
Examples
-
Draw line:
-
Draw circle:
-
Stroke text:
-
Linear & Circular Gradients:
-
Draw image:
HTML Video
-
<video>element displays video. -
Example:
-
Attributes:
-
controls: show play/pause/volume -
autoplay,muted -
width&heightrecommended
-
-
Supported formats: MP4, WebM, Ogg
HTML Audio
-
<audio>element plays audio. -
Example:
-
Supported formats: MP3, WAV, OGG
HTML Plug-ins
-
<object>&<embed>elements embed external content (like PDFs, images, HTML files). -
<object>example:
-
<embed>example:
-
Most old plug-ins (Java applets, Flash, ActiveX) are no longer supported.
HTML URLs
-
Uniform Resource Locator (URL): web address.
-
Syntax:
-
Example:
-
Common schemes:
-
http, https, ftp, file
-
-
URL encoding:
-
Converts non-ASCII characters to
%+ hex digits -
Spaces →
%20or+ -
Default charset in HTML5: UTF-8
-
