HTML Under the Hood: How HTML Really Works Behind the Scenes
How HTML Really Works Behind the Scenes

Search for a command to run...
How HTML Really Works Behind the Scenes

No comments yet. Be the first to comment.
Large language models can answer questions, write content, summarize information, and help with many other tasks. However, they have one important limitation: they do not automatically know everything

Uploading images directly from an Expo app to Amazon S3 can make your uploads faster and reduce work on your backend server. However, you should never put AWS access keys inside your Expo app. Anyone

Today, you do not need to pay for an AI API just to test AI models. You can run many open-source or open-weight AI models directly on your own laptop or PC. This means the model runs on your machine,

Deploying for Indian user data safety

Why I spent 3 years manually excluding IDE files from every single repo (and how one config line fixed everything)

On this page
Hyper Text Markup Language
This just means text with links.
When you click on a link to go to another pagethatβs hypertext.
So HTML lets you connect pages together with <a> tags (links).
Markup means tags that tell the browser how to structure and display content.
Example:
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
Youβre not writing the content alone youβre marking it up to say what it is: a heading, a paragraph, a link, etc.
HTML is a computer language, but not like Python or JavaScript.
It doesnβt have logic or calculations just structure.
Think of it like this:
HTML is the skeleton of a webpageit defines whatβs on the page and in what order.
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
</head>
<body>
<h1>Hello!</h1>
<p>This is my first webpage.</p>
<a href="https://google.com/">Go to Google</a>
</body>
</html>
Imagine a browser (like Chrome, Firefox, Safari) as a super-fast reader. When you open a web page:
Browser gets HTML code from a server.
It reads the HTML line by line (top to bottom).
It builds a visual structure called the DOM (Document Object Model).
Then it draws what you see on the screen text, images, buttons, etc.
The DOM is an in-memory tree-like data structure that the browser creates from HTML.
Itβs not HTML, but a representation of it that JavaScript and the browser can interact with.
Every HTML element becomes a node in the tree.
The structure of your HTML defines the parent-child relationships between those nodes.

The root of every DOM is Document.
Inside the <html> element, we have two main children:
<head> with a <title> that contains text.
<body> with three elements:
<h1>: heading text
<p>: a paragraph
<a>: a link with text and an attribute (href)
Each element node (like <h1>) can have text nodes or child elements inside.
HTML is made up of tags, like <p> or <h1>. Most tags come in pairs:
<p>This is a paragraph.</p>
<p> = opening tag
</p> = closing tag
Content goes in between.
There are also self-closing tags, like:
<img src="cat.jpg" alt="Cute cat">
<img> inserts an image. It doesnβt wrap anything, so itβs self-closing.When you enter a URL:
The browser sends an HTTP request to the server.
The server responds with an HTML file.
The browser starts reading it before it's fully downloaded (this is called streaming parsing).
The browser breaks the raw HTML text into tokens:
Example HTML:
<p>Hello <b>world</b></p>
Becomes tokens like:
Start tag <p>
Text node Hello
Start tag <b>
Text node world
End tag </b>
End tag </p>
The tokens are converted into nodes and attached to the DOM tree:
Document
βββ <html>
βββ <body>
βββ <p>
βββ "Hello"
βββ <b>
βββ "world"
Each node has:
A type (element, text, comment, etc.)
Attributes
Children
A reference to its parent
Browsers are forgiving. Even if you write messy HTML, they try to fix it. For example:
<p>Hello
<b>world
Will be interpreted and closed properly in the DOM as if you had written the full:
<p>Hello <b>world</b></p>
Browsers have error recovery logic based on the HTML5 spec.
When the parser encounters a <script> tag without async or defer, it:
Pauses DOM construction.
Runs the script (because it might modify the DOM).
Resumes parsing after the script runs.
Thatβs why putting <script> at the bottom of the page or using defer is good for performance.
Once parsing is complete, the browser has a full DOM Tree in memory. Example simplified tree:
Document
βββ html
βββ head
β βββ title β "My Page"
βββ body
βββ h1 β "Welcome"
βββ p β "Hello World"
This is what JavaScript talks to when you do things like:
document.querySelector("h1").textContent = "Changed!";
You're not modifying raw HTML youβre modifying the DOM structure in memory.
Thanks for reading π
I'm Aman, a freelance web developer.
I love building clean, functional websites and apps.
I'm open to work, collaborations, or just a good tech chat.
π¬ Reach out or follow me: