What is HTML?
HTML stands for HyperText Markup Language. It is the standard markup language used to create web pages. HTML describes the structure of a web page using a series of elements. These elements instruct the browser on how to display the content.
Basic Concepts
- HTML elements label pieces of content and define how it should be displayed. For example, they can indicate headings, paragraphs, links, and more.
- An HTML document consists of a hierarchy of elements nested within one another.
A Simple HTML Document
Here is a basic example of an HTML document:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
Example Explained
<!DOCTYPE html>
This declaration defines the document as an HTML5 document. It helps the browser to display the page correctly.<html>
The root element of an HTML page. It wraps all the content of the document.<head>
Contains meta-information about the HTML document, such as the title and links to stylesheets or scripts.<title>
Specifies the title of the page, which appears in the browser’s title bar or tab.<body>
Contains the content of the document that is visible to users, such as headings, paragraphs, images, links, etc.<h1>
Defines a large heading. HTML allows six levels of headings (<h1>
to<h6>
), with<h1>
being the most important.<p>
Defines a paragraph of text.
What is an HTML Element?
An HTML element is a fundamental building block of HTML. It is defined by a start tag, content, and end tag.
Structure of an HTML Element:
htmlCopy code<tagname> Content goes here... </tagname>
- Start Tag:
<tagname>
- Content: The content inside the tags
- End Tag:
</tagname>
Examples:
htmlCopy code<h1>My First Heading</h1>
<p>My first paragraph.</p>
<h1>
: The start tag for a heading elementMy First Heading
: The content of the heading</h1>
: The end tag for the heading element<p>
: The start tag for a paragraph elementMy first paragraph.
: The content of the paragraph</p>
: The end tag for the paragraph element
htmlCopy code<br>
<br>
: Inserts a line break in the text.