HTML is the main content for every web page. It helps you structure text, links, and media. You can build pages that browsers convert into a well-designed page.
What is HTML?
HTML stands for HyperText Markup Language, which tells the browser how to show content. So, each web page you see on the internet has HTML.
A web page can hold many elements, such as:
- Text
- Links
- Images
- Forms
And other parts through HTML tags.
You need HTML because no page exists online without it. HTML gives order to a page. A browser reads HTML to know how to display content.
A page shows text without style or links if there is no HTML. HTML also helps you add CSS and JavaScript to the web page.
An HTML page has a root element called <html>. You have a <head> part and a <body> part inside it. The head part places the title and metadata, while the body part shows the visible page content.
Here is an example:
<!DOCTYPE html>
<html>
<head>
<title>My First Page</title>
</head>
<body>
<h1>Hello World</h1>
<p>This is my page.</p>
</body>
</html>
This returns a page with a title in the browser tab and a heading with a paragraph.
An element has an opening tag, content, and a closing tag. For example <p>Hello</p> has a tag <p>, text content, and a closing </p>.
Some tags do not need a closing part, such as <br> or <img>. Tags define the role of content in the document.
How to Write Your First HTML Page
You write HTML in a plain text editor and save it as .html. Then you open that file in a browser to see the result.
Start with a <!DOCTYPE html> line, then add <html>, <head>, and <body>. Inside the body, add headings, paragraphs, and links to shape your page.
Here is an example:
<!DOCTYPE html>
<html>
<head>
<title>Sample Page</title>
</head>
<body>
<h1>Welcome</h1>
<p>This is a sample paragraph.</p>
<a href="https://example.com">Visit Example</a>
</body>
</html>This shows a title in the tab, a main heading, a paragraph, and a link.
Attributes give extra data to elements. They sit inside the opening tag.
For example <a href="https://site.com">Link</a> has an href attribute.
It tells the browser where the link should go.
For example:
<img src="photo.jpg" alt="Profile Photo">This loads an image and shows text if the image does not load.
You can place elements inside other elements. For example, you can put a <strong> tag inside a <p>. Browsers read elements from top to bottom in the source order. That order affects how users and screen readers view the page.
So, how do browsers read and render HTML?
A browser reads HTML code line by line. It builds a tree of nodes called the DOM. That tree tells the browser what elements exist and how they link. The browser then draws the final page on the screen.
Examples
Blog Post:
<!DOCTYPE html>
<html>
<head>
<title>Blog</title>
</head>
<body>
<article>
<h1>My Post</h1>
<p>This is the start of my first blog post.</p>
</article>
</body>
</html>This code shows a blog post with a title and a short text inside an article tag.
Navigation Menu:
<!DOCTYPE html>
<html>
<head>
<title>Menu</title>
</head>
<body>
<nav>
<a href="home.html">Home</a>
<a href="about.html">About</a>
<a href="contact.html">Contact</a>
</nav>
</body>
</html>Navigation Menu:
<!DOCTYPE html>
<html>
<head>
<title>Menu</title>
</head>
<body>
<nav>
<a href="home.html">Home</a>
<a href="about.html">About</a>
<a href="contact.html">Contact</a>
</nav>
</body>
</html>This shows three links inside a nav element. Each link points to a page.
Profile Card:
<!DOCTYPE html>
<html>
<head>
<title>Profile</title>
</head>
<body>
<section>
<h2>John Doe</h2>
<img src="john.jpg" alt="John Photo">
<p>Email: john@example.com</p>
</section>
</body>
</html>This example shows a profile with a name, an image, and contact data.
Form with Input:
<!DOCTYPE html>
<html>
<head>
<title>Form</title>
</head>
<body>
<form action="/submit" method="post">
<label>Name:</label>
<input type="text" name="username">
<button type="submit">Send</button>
</form>
</body>
</html>This code shows a form with a text field and a button. The form tag sends the user data to the server path defined in the action attribute.
Wrapping Up
You learned what HTML is and how it works. You also learned about elements, tags, attributes, and document flow. Here is a quick recap:
- HTML tells the browser how to show page content.
- A document has a head and body parts.
- Elements and attributes give role and data.
- Nesting and semantic tags add order and meaning.
- Browsers read HTML into a DOM tree and then show the page.
FAQs
What is HTML Introduction for Beginners?
<html>.
Basic format looks like:
<!DOCTYPE html>
<html>
<head>
<title>My First Page</title>
</head>
<body>
<h1>Hello World</h1>
<p>This is my first HTML page.</p>
</body>
</html>How do beginners write their first HTML page?
- Open a text editor like Notepad.
- Write code with root
<html>element. - Save file with extension
.html. - Open file in browser to view.
<!DOCTYPE html>
<html>
<head>
<title>First Page</title>
</head>
<body>
<p>Welcome to my HTML page.</p>
</body>
</html>
What are common HTML tags for beginners?
<h1> to <h6>→ Headings<p>→ Paragraph<a>→ Link<img>→ Image<ul> and <li>→ List<div>→ Section container
<h1>HTML Example</h1>
<p>Learning HTML tags is easy.</p>
<a href="https://example.com">Visit Site</a>
Why should beginners learn HTML first?
Similar Reads
Use the <base> tag in HTML to set a single base URL or target for all relative links and resources…
The script tag adds JavaScript to a web page in HTML. This lets the page run logic or load content.…
The HTML ARIA attributes help users with disabilities use websites. These attributes describe roles and states for tools. Understand the…
The dir attribute tells the browser which way text should go in HTML. You use it when a page or…
The abbr tag refers to an abbreviation in HTML. It helps you save space and improve accessibility. The screen readers…
Purpose and use cases: The HTML meter tag shows a scalar value within a known range. You can use it…
HTML select tag and option tags let users pick values in a form. You use them to create dropdowns. The…
The nav tag defines a navigation block in HTML. It holds main links to other parts of your site. Search…
The heading elements define a content structure in HTML. Use <h1> to <h6> to show levels. <h1> means the main…
The HTML bdi tag marks text that has an unknown or mixed direction. It makes sure that this part does…