What is HTML?
HTML stands for HyperText Markup Language.
- HyperText: Refers to text that serves as a link, allowing navigation between web pages.
- Markup Language: Refers to using tags to define elements and structure within a document.
When a browser processes an HTML file, it uses the tags to create layouts, insert images, and link documents. HTML is written in text editors such as VS Code, Sublime Text, Atom, or Notepad. Every HTML file must have the extension .html
.
Important Rule: There should only be one <body>
tag in an HTML document.
Usefulness of HTML
- Learn by Viewing Others’ Work
- HTML allows you to view the source code of any web page. This makes it possible to learn new techniques and replicate features.
- Customize Beyond Editors
- Some editors might not recognize certain tags or fail to meet your needs. With knowledge of HTML, you can directly write or modify the source code.
- Empower Your Creativity
- Knowing HTML gives you full control over the structure and content of your web pages.
Structure of an HTML Document
The basic structure of an HTML document comprises five elements:
- DOCTYPE Declaration (
<!DOCTYPE>
):
Declares the version of HTML being used. For HTML5, it looks like: - HTML Tag (
<html>
):
Encloses the entire document. - Head Tag (
<head>
):
Contains meta-information, such as the title and links to stylesheets. - Title Tag (
<title>
):
Specifies the title displayed on the browser tab. - Body Tag (
<body>
):
Contains all visible content on the webpage, such as text, images, and links.
Basic HTML Tags
- Paragraph Tag (
<p>
):
Used to define a paragraph. - Heading Tags (
<h1>
to<h6>
):
Used to define headings, from largest (<h1>
) to smallest (<h6>
). - Anchor Tag (
<a>
):
Creates hyperlinks to other pages or locations. - Image Tag (
<img>
):
Embeds an image in the document.Note: The
<img>
tag does not have a closing tag. - Division Tag (
<div>
):
Groups content into sections.
HTML Is Not a Programming Language
Although HTML is widely used to create web pages, it is not a programming language because:
- No Logic
- HTML does not contain loops, conditional statements (e.g.,
if/else
), or any logic-based constructs.
- HTML does not contain loops, conditional statements (e.g.,
- No Variables or Functions
- HTML cannot store data or execute functions.
- No Input-Output Capability
- It cannot take inputs or produce outputs in the traditional sense (this requires a programming language like JavaScript).
- No Mathematical Computation
- HTML cannot perform calculations or manipulate data.