tutorials code home
html.png

HTML Basics: Structuring Your First Web Page

Welcome to our HTML Basics tutorial! In this tutorial, we'll cover the fundamental HTML elements and structure to create a basic web page.

Introduction to HTML

HTML (Hypertext Markup Language) is the standard markup language used to create web pages. It's the backbone of a website, providing the structure and content that the web browser renders to the user.

Basic HTML Structure

Every HTML document starts with the following basic structure:

  <!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<!-- page content here -->
</body>
</html>

Let's break it down:


- <!DOCTYPE html>: Declares the document type as HTML5.
- <html>: The root element of the HTML document.
- <head>: Contains metadata about the document, such as the title, charset, and links to external stylesheets or scripts.
- <title>: Sets the title of the page, displayed in the browser's title bar and search engine results - <body>: Contains the content of the HTML document.

Headings and Paragraphs

Headings and paragraphs are basic HTML elements used to structure content.


- Headings: <h1>, <h2>, <h3>, etc. represent headings of different levels.
- Paragraphs: <p> represents a paragraph of text.
Example:
<h1>Main Heading</h1>
<p>This is a paragraph of text.</p>

Links and Images


Links and images are essential elements in HTML.


- Links: <a> represents a hyperlink to another web page or email address.
- Images: <img> represents an image file.
Example:
<a href="#">Visit</a> <img src="image.jpg" alt="An image on the page">

Lists and Tables


Lists and tables help organize content.


- Unordered Lists: <ul> represents an unordered list, with <li> representing each list item.
- Ordered Lists: <ol> represents an ordered list, with <li> representing each list item.
- Tables: <table> represents a table, with <tr> representing each table row and <td> representing each table data cell.

Example: <ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<table>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</table>

Forms and Inputs


Forms and inputs allow users to interact with the web page.


- Forms: <form> represents a form, with <input>, <textarea>, and <select> representing different input fields.


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

Conclusion and Next Steps

Congratulations! You've learned the basic HTML elements and structure. Practice building your own web page using this tutorial as a reference. In the next tutorial, we'll explore CSS basics to style your web page.

Frequently Asked Questions

What is HTML?
HTML stands for "HyperText Markup Language". It's a standard markup language used to create web pages.
What is the basic structure of an HTML document?
The basic structure includes the <!DOCTYPE html>, <html>, <head>, and <body> elements.
What is the difference between <div> and <span>?
<div> is a block-level element, while <span> is an inline element.
How do I add an image to a web page?
Use the <img> element with the src attribute to specify the image URL.
What is the purpose of the <head> section?
The <head> section contains metadata about the document, such as the title, charset, and links to external stylesheets or scripts.
How do I create a hyperlink?
Use the <a> element with the href attribute to specify the link URL.
What is the difference between <ul>, <ol>, and <dl>?
<ul> is an unordered list, <ol> is an ordered list, and <dl> is a definition list.
How do I add a comment to an HTML document?
Use <!-- to start and --> to end the comment.
What is the purpose of the <title> element?
The <title> element sets the title of the page, which appears in the browser's title bar and search engine results.
How do I create a table in HTML?
Use the <table> element, along with <tr> for table rows, <td> for table data cells, and <th> for table header cells.
What is the difference between <strong> and <b>?
<strong> indicates strong importance or emphasis, while <b> simply bolds the text.