Week 1: HTML Basics
HTML | Structure, Tags, Lists, Links, Images, Tables
Web Development 1
WEEK 01
1. What is HTML?
HTML stands for HyperText Markup Language. It is the standard language used to create and structure content on the World Wide Web. Every website you visit is built with HTML as its foundation.
HTML is not a programming language. It is a markup language that uses tags (also called elements) to describe the structure of a web page. Think of HTML as the skeleton of a webpage — it defines what content exists and how it is organized, but not how it looks (that is the job of CSS) or how it behaves (that is the job of JavaScript).
Key Facts About HTML
- Created by Tim Berners-Lee in 1991
- Current version: HTML5 (released in 2014, continuously updated)
- Maintained by W3C (World Wide Web Consortium) and WHATWG
- HTML files use
.html or .htm extension
- Can be created with any text editor (VS Code, Notepad, Sublime Text, etc.)
What Does HTML Look Like?
HTML uses tags enclosed in angle brackets. Most tags come in pairs: an opening tag and a closing tag.
<!-- This is the most basic HTML example -->
<p>Hello, World! This is a paragraph.</p>
<!-- Tags wrap around content -->
<h1>This is a heading</h1>
<p>This is a paragraph of text.</p>
Anatomy of an HTML Element
An HTML element consists of:
- Opening tag:
<tagname>
- Content: The text or other elements inside
- Closing tag:
</tagname>
Some elements are self-closing (also called void elements) and do not have a closing tag, like <br>, <hr>, <img>.
HTML Elements vs. Tags vs. Attributes
| Term |
Description |
Example |
| Tag |
The markup syntax: opening or closing |
<p> or </p> |
| Element |
The complete structure: opening tag + content + closing tag |
<p>Hello</p> |
| Attribute |
Extra information added to the opening tag |
<a href="url"> |
<!-- Element with attributes -->
<a href="https://example.com" target="_blank">Click me</a>
<!-- Self-closing element with attributes -->
<img src="photo.jpg" alt="A photo" width="300">
2. How Browsers Work
A web browser (Chrome, Firefox, Edge, Safari) is a software application that retrieves, interprets, and displays web content. When you type a URL or click a link, the browser performs several steps.
The Request-Response Cycle
- You type a URL (e.g.,
https://www.example.com) in the address bar.
- DNS Lookup: The browser translates the domain name into an IP address using the Domain Name System.
- HTTP Request: The browser sends an HTTP request to the web server at that IP address.
- Server Response: The server sends back HTML, CSS, JavaScript, images, and other files.
- Parsing & Rendering: The browser parses the HTML, applies CSS styles, executes JavaScript, and renders the page on screen.
How the Browser Renders HTML
- Parse HTML: The browser reads the HTML from top to bottom, building a DOM (Document Object Model) tree.
- Parse CSS: The browser reads CSS and creates a CSSOM (CSS Object Model).
- Combine: The DOM and CSSOM are combined into a Render Tree.
- Layout: The browser calculates the position and size of each element.
- Paint: The browser draws the pixels on the screen.
What is the DOM?
The Document Object Model (DOM) is a tree-like representation of the HTML document. Each HTML element becomes a node in this tree. JavaScript uses the DOM to access and manipulate elements on the page.
Your First HTML Page
To create your first web page, all you need is a text editor and a browser:
- Open a text editor (VS Code recommended)
- Create a new file called
index.html
- Type your HTML code
- Save the file
- Double-click the file to open it in a browser
<!-- Save this as index.html and open in a browser -->
<!DOCTYPE html>
<html>
<head>
<title>My First Page</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>Welcome to my first HTML page.</p>
</body>
</html>
3. HTML Document Structure
Every HTML document follows a specific structure. Think of it as a template that every web page must use.
The Complete HTML5 Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page Title Here</title>
</head>
<body>
<!-- All visible content goes here -->
<h1>Welcome to My Website</h1>
<p>This is the body of the page.</p>
</body>
</html>
Breaking Down Each Part
1. <!DOCTYPE html>
This declaration tells the browser that this document is written in HTML5. It must be the very first line. It is not an HTML tag; it is an instruction to the browser.
<!-- Always the first line of an HTML document -->
<!DOCTYPE html>
2. <html> - The Root Element
The <html> element wraps all content on the page. The lang attribute specifies the language.
<html lang="en">
<!-- Everything goes inside html -->
</html>
<!-- For Arabic pages: -->
<html lang="ar" dir="rtl">
</html>
3. <head> - The Document Head
The <head> contains metadata about the page. This content is not displayed on the page itself, but is used by the browser, search engines, and other tools.
<head>
<!-- Character encoding - always use UTF-8 -->
<meta charset="UTF-8">
<!-- Responsive design viewport settings -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Page description for search engines -->
<meta name="description" content="A description of this page">
<!-- Author of the page -->
<meta name="author" content="Your Name">
<!-- The page title shown in the browser tab -->
<title>My Amazing Website</title>
<!-- Link to an external CSS stylesheet -->
<link rel="stylesheet" href="styles.css">
</head>
4. <body> - The Document Body
The <body> contains all the content that is visible to the user: text, images, links, videos, forms, etc.
<body>
<h1>This heading is visible</h1>
<p>This paragraph is visible</p>
<img src="cat.jpg" alt="A cute cat">
</body>
Head vs. Body - Summary
<head> |
<body> |
| Not visible on the page |
Visible to the user |
| Contains metadata |
Contains actual content |
| title, meta, link, style, script |
h1-h6, p, img, a, div, etc. |
HTML Comments
Comments are notes in your code that the browser ignores. They are useful for explaining your code to other developers (or to your future self).
<!-- This is a comment. The browser will not display it. -->
<!--
This is a multi-line comment.
You can write as many lines as you want.
Very useful for documenting sections of your code.
-->
<p>This text is visible.</p>
<!-- <p>This text is hidden because it is inside a comment.</p> -->
4. Headings & Paragraphs
Headings: <h1> to <h6>
HTML provides six levels of headings. <h1> is the most important (largest), and <h6> is the least important (smallest). Headings are used to create a hierarchy of content on your page.
<h1>Heading Level 1 - Main Title</h1>
<h2>Heading Level 2 - Section Title</h2>
<h3>Heading Level 3 - Subsection</h3>
<h4>Heading Level 4 - Sub-subsection</h4>
<h5>Heading Level 5 - Detail</h5>
<h6>Heading Level 6 - Fine Detail</h6>
Important Rules for Headings
- Use only one
<h1> per page (the main title).
- Do not skip levels: go from h1 to h2 to h3, not h1 to h3.
- Do not use headings just to make text big or bold. Use CSS for styling.
- Headings are important for SEO (Search Engine Optimization) and accessibility (screen readers use them for navigation).
Example: Proper Heading Hierarchy
<h1>Web Development Course</h1>
<h2>Chapter 1: Introduction to HTML</h2>
<h3>1.1 What is HTML?</h3>
<h3>1.2 HTML Document Structure</h3>
<h2>Chapter 2: HTML Elements</h2>
<h3>2.1 Text Elements</h3>
<h3>2.2 Lists</h3>
<h4>2.2.1 Unordered Lists</h4>
<h4>2.2.2 Ordered Lists</h4>
Paragraphs: <p>
The <p> element represents a paragraph of text. Browsers automatically add space before and after paragraphs.
<p>This is the first paragraph. It contains some text about HTML.
HTML is the foundation of web development.</p>
<p>This is the second paragraph. The browser automatically
separates paragraphs with space.</p>
<p>Notice that extra spaces and
line breaks
in the source code are collapsed into a single space by the browser.</p>
White Space Collapsing
HTML collapses multiple spaces, tabs, and line breaks into a single space. If you want to force a line break or extra space, you need special elements or entities.
Line Break: <br>
The <br> element inserts a line break within text. It is a self-closing element (no closing tag needed).
<p>This is line one.<br>
This is line two.<br>
This is line three.</p>
<!-- Common use: Address formatting -->
<p>
Al-Aqsa University<br>
Gaza, Palestine<br>
Phone: +970-8-2641303
</p>
Do NOT Overuse <br>
Do not use multiple <br> tags to create space between paragraphs. Use <p> elements instead, and control spacing with CSS.
Horizontal Rule: <hr>
The <hr> element creates a horizontal line (a thematic break) between sections of content. It is also self-closing.
<h2>Section One</h2>
<p>Content of section one...</p>
<hr>
<h2>Section Two</h2>
<p>Content of section two...</p>
5. Text Formatting
HTML provides several elements for formatting text. These elements add semantic meaning to the text, telling the browser (and screen readers) about the importance or purpose of the text.
Bold & Strong: <strong> and <b>
<!-- <strong> = important text (semantic - recommended) -->
<p>This is <strong>very important</strong> information.</p>
<!-- <b> = bold text (visual only - no semantic meaning) -->
<p>This text is <b>bold</b> but not necessarily important.</p>
Italic & Emphasis: <em> and <i>
<!-- <em> = emphasized text (semantic - recommended) -->
<p>You <em>must</em> submit your assignment on time.</p>
<!-- <i> = italic text (visual only) -->
<p>The word <i>algorithm</i> comes from the name Al-Khwarizmi.</p>
Small Text: <small>
<p>Regular text and <small>this is smaller text, often used for fine print.</small></p>
<p><small>© 2026 Al-Aqsa University. All rights reserved.</small></p>
Highlighted Text: <mark>
<p>The exam will cover <mark>chapters 1 through 5</mark> of the textbook.</p>
<p>Search results: The <mark>HTML</mark> tutorial covers all basics of <mark>HTML</mark>.</p>
Deleted & Inserted Text: <del> and <ins>
<!-- <del> = deleted/removed text (shows strikethrough) -->
<!-- <ins> = inserted/added text (shows underline) -->
<p>The price is <del>$50</del> <ins>$35</ins> today only!</p>
<p>The meeting is on <del>Monday</del> <ins>Tuesday</ins>.</p>
Subscript & Superscript: <sub> and <sup>
<!-- <sub> = subscript (lower) -->
<p>Water formula: H<sub>2</sub>O</p>
<p>Carbon Dioxide: CO<sub>2</sub></p>
<!-- <sup> = superscript (upper) -->
<p>E = mc<sup>2</sup></p>
<p>x<sup>2</sup> + y<sup>2</sup> = z<sup>2</sup></p>
<p>10th of October<sup>*</sup></p>
All Text Formatting Summary
| Element |
Purpose |
Appearance |
<strong> |
Important text (semantic) |
Bold |
<b> |
Bold text (visual only) |
Bold |
<em> |
Emphasized text (semantic) |
Italic |
<i> |
Italic text (visual only) |
Italic |
<small> |
Fine print, side comments |
Smaller text |
<mark> |
Highlighted/marked text |
Yellow highlight |
<del> |
Deleted/removed text |
Strikethrough |
<ins> |
Inserted/added text |
Underline |
<sub> |
Subscript |
Lower text |
<sup> |
Superscript |
Upper text |
Combined Example
<p>
The <strong>HTML</strong> specification is maintained by the
<em>World Wide Web Consortium</em> (W3C).
The current version is HTML<sup>5</sup>.
<small>First released in <del>2012</del> <ins>2014</ins>.</small>
The chemical formula for water is H<sub>2</sub>O, and
remember to <mark>study this for the exam</mark>.
</p>
6. Lists
HTML provides three types of lists: unordered lists, ordered lists, and description lists. Lists are used frequently in web pages for navigation menus, features, steps, and more.
Unordered List: <ul>
An unordered list displays items with bullet points. Each item is wrapped in an <li> (list item) element.
<h3>Programming Languages</h3>
<ul>
<li>JavaScript</li>
<li>Python</li>
<li>Java</li>
<li>C++</li>
</ul>
Ordered List: <ol>
An ordered list displays items with numbers (or letters/roman numerals). The order matters.
<h3>How to Make Tea</h3>
<ol>
<li>Boil water</li>
<li>Add tea bag to cup</li>
<li>Pour hot water</li>
<li>Wait 3-5 minutes</li>
<li>Add sugar if desired</li>
<li>Enjoy!</li>
</ol>
Ordered List Attributes
<!-- Start from number 5 -->
<ol start="5">
<li>Item 5</li>
<li>Item 6</li>
</ol>
<!-- Reverse order -->
<ol reversed>
<li>Third place</li>
<li>Second place</li>
<li>First place</li>
</ol>
<!-- Use letters -->
<ol type="A">
<li>Option A</li>
<li>Option B</li>
<li>Option C</li>
</ol>
<!-- type="a" for lowercase, "I" for Roman, "i" for lowercase Roman -->
<ol type="I">
<li>Chapter I</li>
<li>Chapter II</li>
<li>Chapter III</li>
</ol>
Nested Lists
You can place a list inside another list. The inner list goes inside an <li> element of the outer list.
<h3>Web Technologies</h3>
<ul>
<li>Frontend
<ul>
<li>HTML</li>
<li>CSS
<ul>
<li>Flexbox</li>
<li>Grid</li>
</ul>
</li>
<li>JavaScript</li>
</ul>
</li>
<li>Backend
<ul>
<li>Node.js</li>
<li>PHP</li>
<li>Python (Django)</li>
</ul>
</li>
<li>Databases
<ul>
<li>MySQL</li>
<li>MongoDB</li>
</ul>
</li>
</ul>
Mixed Nested Lists
<h3>Course Plan</h3>
<ol>
<li>HTML Fundamentals
<ul>
<li>Document structure</li>
<li>Text elements</li>
<li>Forms</li>
</ul>
</li>
<li>CSS Styling
<ul>
<li>Selectors</li>
<li>Box model</li>
<li>Layout</li>
</ul>
</li>
<li>JavaScript Basics
<ul>
<li>Variables</li>
<li>Functions</li>
<li>DOM manipulation</li>
</ul>
</li>
</ol>
Description List: <dl>
A description list is used for term-definition pairs, like a glossary.
<h3>Web Development Glossary</h3>
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language - the structure of web pages.</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets - the visual presentation of web pages.</dd>
<dt>JavaScript</dt>
<dd>A programming language for adding interactivity to web pages.</dd>
</dl>
7. Links
Links are one of the most important elements in HTML. They connect web pages together, forming the “web” in World Wide Web. The <a> (anchor) element is used to create links.
Basic Link
<!-- Link to another website -->
<a href="https://www.google.com">Visit Google</a>
<!-- Link to a page on your own site -->
<a href="about.html">About Us</a>
<!-- Link to a file in a subfolder -->
<a href="pages/contact.html">Contact</a>
The href Attribute
The href (Hypertext REFerence) attribute specifies where the link goes. It can be:
| Type |
Example |
Description |
| Absolute URL |
https://google.com |
Full web address |
| Relative URL |
about.html |
Page on same site |
| Anchor |
#section1 |
Section on same page |
| Email |
mailto:info@alaqsa.edu.ps |
Opens email client |
| Phone |
tel:+97082641303 |
Opens phone dialer |
Open in New Tab: target="_blank"
<!-- Opens in a new tab -->
<a href="https://www.google.com" target="_blank">Google (new tab)</a>
<!-- Best practice: add rel="noopener noreferrer" for security -->
<a href="https://www.google.com" target="_blank" rel="noopener noreferrer">
Google (new tab - secure)
</a>
Email Links: mailto:
<!-- Simple email link -->
<a href="mailto:info@alaqsa.edu.ps">Email Us</a>
<!-- Email with subject and body -->
<a href="mailto:info@alaqsa.edu.ps?subject=Hello&body=I have a question">
Send Email with Subject
</a>
Phone Links: tel:
<!-- Phone link - especially useful on mobile -->
<a href="tel:+97082641303">Call Us: +970-8-2641303</a>
Anchor Links (Jump to Section): #
Anchor links let you jump to a specific section on the same page. The target section must have an id attribute.
<!-- Navigation with anchor links -->
<nav>
<a href="#introduction">Introduction</a>
<a href="#features">Features</a>
<a href="#contact">Contact</a>
</nav>
<!-- Sections with id attributes -->
<section id="introduction">
<h2>Introduction</h2>
<p>Welcome to our website...</p>
</section>
<section id="features">
<h2>Features</h2>
<p>Our amazing features...</p>
</section>
<section id="contact">
<h2>Contact</h2>
<p>Get in touch...</p>
</section>
<!-- Link back to top -->
<a href="#">Back to Top</a>
Download Link
<!-- Force download instead of opening -->
<a href="files/resume.pdf" download>Download My Resume</a>
<!-- Download with a custom filename -->
<a href="files/doc123.pdf" download="my-resume.pdf">Download Resume</a>
Image as a Link
<!-- Wrap an image inside a link -->
<a href="https://www.alaqsa.edu.ps">
<img src="university-logo.png" alt="Al-Aqsa University" width="200">
</a>
Best Practices for Links
- Use descriptive link text (not “click here”)
- Always add
target="_blank" with rel="noopener noreferrer"
- Test all links to make sure they work
- Use relative URLs for internal links, absolute URLs for external links
8. Images
Images make web pages visually engaging. The <img> element is used to embed images. It is a self-closing element.
Basic Image
<!-- Basic image -->
<img src="photo.jpg" alt="Description of the photo">
<!-- Image from the internet -->
<img src="https://via.placeholder.com/400x300" alt="Placeholder image">
Required Attributes
| Attribute |
Description |
Required? |
src |
Path to the image file |
Yes |
alt |
Alternative text (if image cannot load, or for screen readers) |
Yes (for accessibility) |
width |
Width in pixels |
Recommended |
height |
Height in pixels |
Recommended |
<!-- Image with all common attributes -->
<img
src="images/campus.jpg"
alt="Al-Aqsa University Campus"
width="600"
height="400"
title="Main campus view"
>
Always Include alt Text!
The alt attribute is essential for:
- Accessibility: Screen readers read the alt text to visually impaired users.
- SEO: Search engines use alt text to understand images.
- Fallback: If the image fails to load, the alt text is displayed instead.
Image Paths
<!-- Same folder as the HTML file -->
<img src="photo.jpg" alt="Photo">
<!-- In a subfolder -->
<img src="images/photo.jpg" alt="Photo">
<!-- In a parent folder -->
<img src="../photo.jpg" alt="Photo">
<!-- Absolute URL from the internet -->
<img src="https://example.com/images/photo.jpg" alt="Photo">
Figure & Figcaption
The <figure> element is used to group an image (or other media) with its caption. The <figcaption> provides the caption text.
<figure>
<img src="sunset.jpg" alt="A beautiful sunset over the sea" width="500">
<figcaption>Figure 1: Sunset over the Mediterranean Sea, Gaza.</figcaption>
</figure>
<!-- Multiple images in a figure -->
<figure>
<img src="before.jpg" alt="Before renovation" width="300">
<img src="after.jpg" alt="After renovation" width="300">
<figcaption>Before and after renovation of the library.</figcaption>
</figure>
Supported Image Formats
| Format |
Extension |
Best For |
| JPEG |
.jpg, .jpeg |
Photos, complex images with many colors |
| PNG |
.png |
Graphics with transparency, screenshots |
| GIF |
.gif |
Simple animations, small graphics |
| SVG |
.svg |
Icons, logos (scales without losing quality) |
| WebP |
.webp |
Modern format, smaller file sizes |
9. Tables
HTML tables are used to display data in rows and columns. They are perfect for showing structured information like schedules, grades, comparison charts, etc.
Tables Are for Data, Not Layout!
In the early days of the web, tables were used for page layout. This is now considered bad practice. Use tables only for tabular data. Use CSS (Flexbox, Grid) for layout.
Basic Table Structure
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
</thead>
<tbody>
<tr>
<td>Ahmed</td>
<td>22</td>
<td>Gaza</td>
</tr>
<tr>
<td>Sara</td>
<td>20</td>
<td>Khan Younis</td>
</tr>
<tr>
<td>Omar</td>
<td>21</td>
<td>Rafah</td>
</tr>
</tbody>
</table>
Table Elements Explained
| Element |
Description |
<table> |
The container for the entire table |
<thead> |
Groups the header row(s) |
<tbody> |
Groups the body rows |
<tfoot> |
Groups the footer row(s) |
<tr> |
Table Row |
<th> |
Table Header cell (bold + centered by default) |
<td> |
Table Data cell |
<caption> |
Table caption/title |
Table with Caption and Footer
<table>
<caption>Student Grades - Fall 2025</caption>
<thead>
<tr>
<th>Student</th>
<th>Midterm</th>
<th>Final</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>Ahmed</td>
<td>85</td>
<td>90</td>
<td>175</td>
</tr>
<tr>
<td>Sara</td>
<td>92</td>
<td>88</td>
<td>180</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Average</td>
<td>88.5</td>
<td>89</td>
<td>177.5</td>
</tr>
</tfoot>
</table>
Colspan & Rowspan
colspan makes a cell span multiple columns. rowspan makes a cell span multiple rows.
<!-- colspan example -->
<table>
<tr>
<th colspan="3">Course Schedule</th>
</tr>
<tr>
<th>Day</th>
<th>Time</th>
<th>Subject</th>
</tr>
<tr>
<td>Monday</td>
<td>9:00 AM</td>
<td>Web Development 1</td>
</tr>
<tr>
<td>Wednesday</td>
<td>11:00 AM</td>
<td>Database Systems</td>
</tr>
</table>
<!-- rowspan example -->
<table>
<thead>
<tr>
<th>Name</th>
<th>Subject</th>
<th>Grade</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2">Ahmed</td>
<td>HTML</td>
<td>95</td>
</tr>
<tr>
<!-- No td for Name - it spans from above -->
<td>CSS</td>
<td>88</td>
</tr>
<tr>
<td rowspan="2">Sara</td>
<td>HTML</td>
<td>92</td>
</tr>
<tr>
<td>CSS</td>
<td>90</td>
</tr>
</tbody>
</table>
Complex Table Example
<table>
<caption>Weekly Schedule</caption>
<thead>
<tr>
<th>Time</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
</tr>
</thead>
<tbody>
<tr>
<td>9:00</td>
<td colspan="2">Web Development Lab</td>
<td rowspan="2">Project Work</td>
</tr>
<tr>
<td>10:00</td>
<td>HTML Lecture</td>
<td>CSS Lecture</td>
</tr>
<tr>
<td>11:00</td>
<td colspan="3">Free Period</td>
</tr>
</tbody>
</table>
Table Best Practices
- Always use
<thead>, <tbody>, and optionally <tfoot> for structure.
- Use
<th> for header cells (not <td> with bold).
- Add a
<caption> to describe the table's purpose.
- Keep tables simple; avoid deeply nested tables.