My Notes

HTML Notes

Table of Content

PHASE 1: FOUNDATIONS OF THE WEB


PHASE 2: TEXT & CONTENT ELEMENTS


PHASE 3: LINKS & MEDIA


PHASE 4: LISTS & TABLES


PHASE 5: FORMS


PHASE 6: SEMANTIC HTML


PHASE 7: HTML IN REAL WORLD


PHASE 1: FOUNDATIONS OF THE WEB

1️⃣ What is HTML? (Simple Truth)

HTML = HyperText Markup Language

It is NOT a programming language.

It does NOT do logic. It does NOT calculate. It does NOT think.

It only:

👉 Structures content on a webpage.

💡 Real-life analogy:

If a website is a house:

  • HTML = structure (walls, rooms, doors)
  • CSS = paint & design
  • JavaScript = electricity & automation

Without HTML → nothing exists.

2️⃣ How Does a Website Actually Load?

Let's break it like engineers:

  • You type: google.com
  • Browser sends request to server
  • Server sends back HTML file
  • Browser reads HTML
  • Browser builds webpage

That's it.

HTML is the first thing browser reads.

3️⃣ What is a Tag?

HTML works using tags.

Example:

<p>Hello</p>
  • <p> → opening tag
  • </p> → closing tag

Together they form an element.

📌 Important:

Most tags have:

<tag> content </tag>

But some are self-closing:

<img />
<br />
<hr />

4️⃣ What is an Element?

Element = Opening tag + content + closing tag

Example:

<h1>Welcome</h1>

This whole thing is one element.

5️⃣ What is an Attribute?

Attributes give extra information to tags.

Example:

<a href="https://google.com">Go to Google</a>

Here: href is an attribute.

General format:

<tag attribute="value">

💡 Engineering analogy:

  • Tag = machine
  • Attribute = configuration setting

6️⃣ Basic HTML Structure (Boilerplate)

Every HTML file starts like this:

<!DOCTYPE html>
<html>
<head>
    <title>My Page</title>
</head>
<body>

    <h1>Hello World</h1>

</body>
</html>

Let's decode it:

  • <!DOCTYPE html> → tells browser this is HTML5
  • <html> → root element
  • <head> → invisible info (title, meta)
  • <body> → visible content

7️⃣ Indentation (Just Like Python 😎)

HTML ignores indentation, BUT humans don't.

Bad:

<html><body><h1>Hi</h1></body></html>

Good:

<html>
   <body>
      <h1>Hi</h1>
   </body>
</html>

Readable code = professional code.

8️⃣ Comments in HTML

Used to write notes in code:

<!-- This is a comment -->

Browser ignores it.

🧠 PHASE 2: TEXT & CONTENT ELEMENTS

(Where your webpage finally starts looking alive)

Think of this phase like: 👉 Adding furniture inside the house structure we built in Phase 1.

1️⃣ Headings (Hierarchy of Importance)

HTML gives us 6 heading levels:

<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>

📌 Important:

  • <h1> = most important
  • <h6> = least important
  • You should use only ONE <h1> per page (SEO rule)

💡 Engineering analogy:

Think of headings like:

  • H1 → Project Title
  • H2 → Module Name
  • H3 → Submodule
  • H4 → Feature inside submodule

It creates a proper structure.

🚨 Common Mistake:

Don't use <h1> because it looks big.

Use headings for meaning, not size.

Size is CSS job.

2️⃣ Paragraph Tag <p>

Used to write normal text.

<p>This is a paragraph.</p>

Browser automatically adds spacing between paragraphs.

💡 Important:

HTML ignores extra spaces and line breaks.

This:

<p>Hello     world</p>

Still shows: Hello world

HTML collapses whitespace.

3️⃣ Line Break <br>

Used when you want to break line manually.

Hello<br>
World

Output: Hello
World

📌 Self-closing tag.

4️⃣ Horizontal Rule <hr>

Creates a horizontal line.

<hr>

Used to separate sections visually.

💡 Engineering analogy:

Like dividing two sections in documentation.

5️⃣ Text Formatting Tags (Visual vs Meaning)

Now comes something very important.

There are two types of formatting:

  • Visual formatting
  • Semantic (meaning-based) formatting

🔹 Bold Text

<b>Bold text</b>
<strong>Important text</strong>

Difference:

  • <b> → just makes text bold
  • <strong> → says this text is important (SEO + accessibility)

👉 Use <strong> in real projects.

🔹 Italic Text

<i>Italic text</i>
<em>Emphasized text</em>

Difference:

  • <i> → just italic style
  • <em> → adds emphasis meaning

👉 <em> is better.

💡 Engineering thinking:

HTML is about meaning. CSS is about styling.

6️⃣ The <pre> Tag (Very Important for Notes App 😎)

Preformatted text.

It keeps:

  • Spaces
  • Line breaks
  • Indentation

Example:

<pre>
def add(a, b):
    return a + b
</pre>

Without <pre>, indentation will break.

📌 You'll use this a LOT in your coding notes app.

7️⃣ Superscript & Subscript

Used in formulas.

H<sub>2</sub>O
x<sup>2</sup>

Output: H2O x2

Used in math and chemistry content.

8️⃣ Semantic vs Non-Semantic (VERY IMPORTANT CONCEPT)

Bad thinking:

"I use whatever tag looks good."

Good thinking:

"I use tag based on meaning."

Example:

Wrong:

<b>Warning</b>

Better:

<strong>Warning</strong>

Because screen readers understand it.

💡 This matters for:

  • SEO
  • Accessibility
  • Real-world web development

🧠 PHASE 3: LINKS & MEDIA

(This is where your website becomes a real website 🌍)

Without links, a website is just a digital poster.

With links → it becomes a network.

1️⃣ Anchor Tag <a> (Most Important Tag After <p>)

Used to create links.

Basic syntax:

<a href="https://google.com">Go to Google</a>

Breakdown:

  • <a> = anchor tag
  • href = destination
  • Text inside = clickable part

💡 Real-life analogy:

Anchor tag is like a door.

href is where that door leads.

2️⃣ Internal vs External Links

🔹 External Link

Goes to another website.

<a href="https://leetcode.com">LeetCode</a>

🔹 Internal Link

Goes to another page inside your project.

<a href="/about.html">About Page</a>

📌 In Next.js, this becomes <Link> component later.

3️⃣ target="_blank" (Open in New Tab)

<a href="https://google.com" target="_blank">
   Open Google
</a>

Opens in new tab.

💡 Use this for:

  • External websites
  • Practice links (like your LeetCode page)

4️⃣ The title Attribute

Adds tooltip on hover.

<a href="https://google.com" title="Search Engine">
   Google
</a>

Small thing. But makes site feel professional.

5️⃣ Image Tag <img>

Adds images.

<img src="image.jpg" alt="Laptop image">

Breakdown:

  • src → image path
  • alt → alternative text

🚨 VERY IMPORTANT: alt Attribute

If image fails to load, alt text appears.

Also:

  • Screen readers read alt text.
  • SEO reads alt text.

💡 Engineering rule:

Never use <img> without alt.

Bad:

<img src="photo.jpg">

Good:

<img src="photo.jpg" alt="Team working on project">

6️⃣ Local vs Online Image

🔹 Online Image

<img src="https://example.com/pic.jpg">

🔹 Local Image

<img src="images/pic.jpg">

Relative path matters.

7️⃣ Width & Height

<img src="pic.jpg" width="300" height="200">

⚠️ Not recommended in real projects.

Use CSS instead.

8️⃣ Audio Tag

<audio controls>
   <source src="audio.mp3">
</audio>

controls → shows play button.

9️⃣ Video Tag

<video width="320" height="240" controls>
   <source src="video.mp4">
</video>

Adds video player.

🔟 Absolute vs Relative Path (Important Concept)

Absolute:

https://example.com/page

Relative:

/about
../images/pic.jpg

Engineering analogy:

  • Absolute = full GPS address
  • Relative = "go 2 steps left"

1️⃣1️⃣ Link vs Button (Common Confusion)

Use:

  • <a> → navigation
  • <button> → action

Wrong:

Using <button> to go to another page.

Correct:

Use <a> for navigation.

🧠 PHASE 4: LISTS & TABLES

(This is where HTML becomes structured like real data)

Think of this phase like: 👉 Turning random notes into organized documentation.

🟢 PART 1: LISTS

Lists are used everywhere:

  • Features list
  • Navigation menus
  • Steps
  • FAQs
  • Sidebar content

1️⃣ Unordered List <ul> (Bullet List)

Used when order doesn't matter.

<ul>
  <li>Python</li>
  <li>HTML</li>
  <li>CSS</li>
</ul>

Output: • Python • HTML • CSS

💡 Engineering thinking:

Use <ul> when sequence is not important.

2️⃣ Ordered List <ol> (Numbered List)

Used when order matters.

<ol>
  <li>Install Python</li>
  <li>Write Code</li>
  <li>Run Program</li>
</ol>

Output:

  1. Install Python
  2. Write Code
  3. Run Program

💡 Use <ol> when:

  • Steps
  • Instructions
  • Ranking

3️⃣ Nested Lists (VERY COMMON)

Lists inside lists.

<ul>
  <li>Frontend
    <ul>
      <li>HTML</li>
      <li>CSS</li>
    </ul>
  </li>
</ul>

Used for:

  • Sidebar menus
  • Table of contents
  • Categories

4️⃣ Definition List (Less Used but Important)

<dl>
  <dt>HTML</dt>
  <dd>Structure of web</dd>

  <dt>CSS</dt>
  <dd>Styling of web</dd>
</dl>
  • <dt> → term
  • <dd> → description

Good for documentation sites.

🧠 LIST MEMORY ANCHORS

  • <ul> = bullets
  • <ol> = numbers
  • <li> = list item
  • Lists can be nested

🟢 PART 2: TABLES

Tables are used to display structured data.

Example:

  • Student data
  • Pricing
  • Timetable
  • Comparison chart

5️⃣ Basic Table Structure

<table>
  <tr>
    <th>Name</th>
    <th>Age</th>
  </tr>

  <tr>
    <td>Alex</td>
    <td>20</td>
  </tr>
</table>

Breakdown:

  • <table> → container
  • <tr> → table row
  • <th> → header cell
  • <td> → data cell

💡 Engineering analogy:

Think of table like Excel sheet:

  • Row → horizontal
  • Column → vertical

6️⃣ Table Head & Body (Professional Structure)

Better version:

<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Age</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>Alex</td>
      <td>20</td>
    </tr>
  </tbody>
</table>

Why use <thead> and <tbody>?

  • Better structure
  • Better accessibility
  • Better styling control

7️⃣ Colspan & Rowspan (Interview Favorite)

🔹 Colspan (Merge Columns)

<td colspan="2">Merged Cell</td>

🔹 Rowspan (Merge Rows)

<td rowspan="2">Merged</td>

Used when:

  • Merging cells
  • Creating complex layouts

💡 Engineering thinking:

Like merging cells in Excel.

8️⃣ Tables Are NOT For Layout

Old developers used tables to design whole websites.

That is WRONG.

Tables are only for tabular data.

Layout should be done using CSS.

🧠 TABLE MEMORY ANCHORS

  • <table> = container
  • <tr> = row
  • <th> = header
  • <td> = data
  • <thead> & <tbody> = clean structure
  • colspan & rowspan merge cells

🟠 PHASE 5: FORMS (MOST IMPORTANT FOR FULL STACK)

This is where HTML becomes interactive.

Without forms: Website = brochure

With forms: Website = application

Examples:

  • Login
  • Signup
  • Search
  • Feedback
  • Payment

All depend on forms.

1️⃣ Basic Form Structure

<form>
   <input type="text">
</form>

<form> wraps all input fields.

2️⃣ The <input> Tag (The Most Powerful Element)

Basic:

<input type="text">

But input has many types.

3️⃣ Important Input Types

🔹 Text

<input type="text">

For names, search, etc.

🔹 Password

<input type="password">

Hides characters.

🔹 Email

<input type="email">

Browser validates email format automatically.

🔹 Number

<input type="number">

Accepts only numbers.

🔹 Date

<input type="date">

Shows calendar.

🔹 Radio (Single Choice)

<input type="radio" name="gender"> Male
<input type="radio" name="gender"> Female

Important:

Same name → only one can be selected.

🔹 Checkbox (Multiple Choice)

<input type="checkbox"> Python
<input type="checkbox"> Java

Multiple allowed.

4️⃣ The label Tag (VERY IMPORTANT)

<label for="name">Name:</label>
<input type="text" id="name">

Why use label?

  • Clicking label focuses input
  • Accessibility
  • Professional coding

5️⃣ The name Attribute (Backend Connector)

This is VERY IMPORTANT.

<input type="text" name="username">

Backend reads data using name.

Without name → backend receives nothing.

6️⃣ Placeholder

<input type="text" placeholder="Enter your name">

Shows hint inside input.

7️⃣ Required Field

<input type="email" required>

Browser prevents submission if empty.

8️⃣ Textarea

For long text:

<textarea rows="4" cols="30"></textarea>

Used in:

  • Feedback
  • Comments
  • Bio

9️⃣ Select & Option (Dropdown)

<select>
   <option>India</option>
   <option>USA</option>
</select>

Better UX than text input for fixed choices.

🔟 Button

<button type="submit">Submit</button>

Important types:

  • submit
  • reset
  • button

1️⃣1️⃣ Form Action & Method (FULL STACK IMPORTANT)

<form action="/submit" method="POST">
  • action → where data goes
  • method → GET or POST

🔹 GET vs POST

GET:

  • Data in URL
  • Used for search

POST:

  • Data hidden
  • Used for login, forms

💡 Engineering thinking:

  • Form = data collector
  • Backend = processor

🧠 PHASE 5 MEMORY ANCHORS

  • name attribute is mandatory
  • label improves accessibility
  • radio = single choice
  • checkbox = multiple
  • GET ≠ POST
  • required = browser validation

🟠 PHASE 6: SEMANTIC HTML (INDUSTRY LEVEL)

Now we move from beginner → professional.

Before HTML5, developers used:

<div>

for everything.

That created messy structure.

Now we use semantic tags.

1️⃣ Why Semantic HTML?

Because:

  • Better SEO
  • Better accessibility
  • Cleaner structure
  • Easier maintenance

2️⃣ Important Semantic Tags

🔹 <header>

Top section of page.

  • Logo
  • Navigation

🔹 <nav>

Navigation links.

  • Menus
  • Sidebar

🔹 <main>

Main content of page.

Only one per page.

🔹 <section>

Logical grouping of content.

Like modules.

🔹 <article>

Independent content.

  • Blog post
  • News article

🔹 <aside>

Side content.

  • Sidebar
  • Ads

🔹 <footer>

Bottom section.

  • Copyright
  • Contact info

💡 Engineering analogy:

Semantic tags = labeled boxes.

Instead of random containers.

3️⃣ SEO Importance

Search engines understand:

  • <h1> importance
  • <article> content
  • <nav> structure

Better SEO ranking.

4️⃣ Accessibility (Very Important)

Screen readers depend on:

  • Proper headings
  • Semantic tags
  • Alt text
  • Labels

Real developers care about accessibility.

🧠 PHASE 6 MEMORY ANCHORS

  • Use meaning-based tags
  • main only once
  • nav for navigation
  • semantic improves SEO

🟠 PHASE 7: HTML IN REAL WORLD

Now we move beyond tags.

1️⃣ DevTools (Your Best Friend)

Right-click → Inspect.

You can:

  • See HTML structure
  • See CSS
  • Debug layout
  • Modify live

Professional developers use this daily.

2️⃣ View Page Source

Shows original HTML from server.

Good for:

  • Learning
  • Inspecting website structure

3️⃣ Common Beginner Mistakes

  • Missing closing tags
  • Using <br> for spacing
  • Using tables for layout
  • Not using semantic tags
  • Forgetting alt attribute

4️⃣ Difference Between HTML, CSS, JS

  • HTML → Structure
  • CSS → Design
  • JS → Logic

If website is human body:

  • HTML = skeleton
  • CSS = skin
  • JS = brain

5️⃣ Static vs Dynamic Website

Static:

  • Pure HTML
  • Same for everyone

Dynamic:

  • Backend involved
  • Content changes
  • Uses databases

6️⃣ HTML Is Not Enough

Modern websites use:

  • HTML
  • CSS
  • JS
  • Frameworks (React, Next.js)

But HTML is always foundation.

Mini Project of using Next.js and Tailwind CSS