Written by Admin Updated 15 min read
Introduction
HTML, or HyperText Markup Language, is the standard markup language used to create webpages.
In this tutorial, you will learn how to create a basic HTML website from scratch. You will create an HTML file, add content, and open the webpage in a browser.
What You Will Learn
What is HTML?
HTML stands for HyperText Markup Language. It defines the structure and content of a webpage.
What You Need
- A computer
- A text editor such as Notepad or VS Code
- A web browser such as Chrome, Firefox, or Edge
🚀 Create Your First HTML Webpage
Step 1: Create an HTML File
Follow these simple steps to create and run your very first HTML webpage.
-
Open a Text Editor
You can use Notepad, Visual Studio Code (VS Code), Sublime Text, Notepad++, or any code editor of your choice.
Step 2: Write Your First HTML Code
-
Create a New File
Save the file with the
.htmlextension. For example:index.html -
Write the HTML Code
Copy and paste the following HTML code into your editor.
Add the following code to your
index.html file:
Step 3: Open the Website
-
Save the File
Ensure the filename is
index.html. -
Open the File in a Browser
- Double-click the HTML file, or right-click and choose Open With → Chrome, Firefox, Edge, or any browser.
- Your webpage will now be displayed.
-
Modify and Refresh
Make changes to the HTML file, save it, and refresh the browser to see the updated webpage.
📘 Basic HTML Structure Explained
<!DOCTYPE html>
Declares that the document uses HTML5.
<html>
The root element that contains the complete webpage.
<head>
Stores metadata including the page title, character encoding, CSS links, and scripts.
<title>
Displays the page title in the browser tab.
<body>
Contains all visible webpage content.
<h1>
Defines the main heading.
<p>
Defines a paragraph.
Step 4: Try Mini Project
Common Problems
index.html, not
index.html.txt.
src attribute.
What's Next?
You have created your first webpage. Now let's understand how HTML structures a webpage and how CSS can be used to style that structure.
Frequently Asked Questions
<p>, <h1>, <a>) to tell the web browser how to format and display content such as text, images, links, and layout elements.
- Tag: The opening or closing marker wrapped in angle brackets (e.g.,
<p>is an opening tag,</p>is a closing tag). - Element: The complete unit consisting of the opening tag, the content inside, and the closing tag (e.g.,
<p>Hello World</p>). - Attribute: Extra information provided inside the opening tag to configure or modify the element (e.g.,
src="image.jpg"in<img src="image.jpg">).
Common Examples:
<img>, <br> (line break), <hr> (horizontal rule), <input>, and <meta>.
<!DOCTYPE html> is an instruction sent to the web browser that specifies the document type and HTML version (HTML5). It must be the very first line of an HTML document to ensure the browser renders the page in standard mode rather than "quirks mode."
- <head>: Contains metadata, page titles, character encodings, links to external CSS stylesheets, and scripts. Nothing inside
<head>is directly displayed on the main webpage canvas (except the<title>shown on the browser tab). - <body>: Contains all the visible content of the webpage, including headings, paragraphs, images, links, tables, and structural containers.
- Block-level Elements: Always start on a new line and take up the full width available (100% of their parent container). Examples:
<div>,<p>,<h1>–<h6>,<ul>,<li>,<form>. - Inline Elements: Do not start on a new line and only take up as much width as their content requires. Examples:
<span>,<a>,<img>,<b>,<i>,<strong>.
<div>is a block-level container used for larger layout sections.<span>is an inline container used to wrap small sections of text or media on the same line.
- Absolute Path: The full URL to an asset on the internet (e.g.,
https://example.com/images/logo.png). - Relative Path: A path relative to the location of the current HTML file (e.g.,
./images/logo.pngor../css/style.css).
alt (alternative text) attribute provides a text description of an image. It is critical for:
- Accessibility: Screen readers read the alt text aloud to visually impaired users.
- SEO: Search engines use alt text to understand image content.
- Fallback: It displays on screen if the image file fails to load.
<header>, <nav>, <main>, <article>, <section>, <footer>) rather than generic <div> tags.
Benefits include:
- Better search engine optimization (SEO).
- Improved web accessibility (a11y) for screen reader tools.
- Cleaner, more readable, and easier-to-maintain code structure.
- <strong> and <em> (Semantic): Indicate semantic emphasis or importance. Screen readers alter their vocal inflection for these tags.
- <b> and <i> (Stylistic): Merely change the visual appearance (bold or italic) without conveying extra meaning or importance.
- <ol> (Ordered List): Renders items in a sequential or numbered order (1, 2, 3...).
- <ul> (Unordered List): Renders items with bullet points without chronological sequence.
- <dl> (Description List): Used for terms (
<dt>) and descriptions (<dd>), ideal for glossaries, metadata, or key-value pairs.
<form> elements send user input via form controls (like <input>, <select>, <textarea>) using the action attribute (destination URL) and method attribute:
- GET: Appends form data to the URL as query parameters (suitable for non-sensitive data/searches).
- POST: Sends form data inside the HTTP request body (suitable for sensitive data, logins, or file uploads).