What is HTML?
HTML stands for HyperText Markup Language. It’s the standard language used to create and design web pages and web applications. HTML elements form the building blocks of web pages.
Basic Structure of an HTML Document
Here’s a simple example of an HTML document structure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document Title</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is a paragraph.</p>
<a href="https://example.com">This is a link</a>
<img src="image.jpg" alt="Description of image">
</body>
</html>
Key Components
<!DOCTYPE html>
: Declares the document type and version of HTML (HTML5 here).<html>
: The root element of the HTML document.<head>
: Contains meta-information about the document, such as its title and character set.<meta charset="UTF-8">
: Specifies the character encoding for the document.<title>
: Sets the title of the document, which appears in the browser tab.<body>
: Contains the content of the web page that users see, such as headings, paragraphs, images, and links.- HTML Elements:
<h1>
to<h6>
: Headings, with<h1>
being the highest level and<h6>
the lowest.<p>
: Paragraph.<a href="URL">
: Anchor tag, used to create hyperlinks.<img src="URL" alt="Description">
: Image tag, used to embed images.
Attributes
HTML elements can have attributes that provide additional information about the element. For example:
href
in<a>
specifies the URL of the link.src
in<img>
specifies the path to the image file.alt
in<img>
provides alternative text for the image.
Common HTML Tags
<div>
: A container for grouping content.<span>
: Inline container for styling small pieces of content.<ul>
,<ol>
,<li>
: Lists (unordered and ordered).
Output:
Example of a Simple HTML Page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First HTML Page</title>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>This is a simple HTML page to get started.</p>
<ul>
<li>avi </li>
<li>anup</li>
<li>maruti</li>
</ul>
</body>
</html>