HTML, which stands for Hypertext Markup Language, is the standard markup language for creating web pages. It describes the structure of a web page using a series of tags.
<!DOCTYPE html>
<html>
<head>
<title>My first page</title>
</head>
<body>
<h1>Welcome!</h1>
<p>This is a simple web page.</p>
</body>
</html>
<body> and </body> tagsIn HTML, most tags have an opening tag and a closing tag. These tags frame the content they affect. Here are the main characteristics:
<p> or <a href="https://www.example.com"></p> or </a>Example of an opening and closing tag
<p>This is a paragraph with an opening tag and a closing tag.</p>
Some HTML tags do not require a closing tag. They are called self-closing tags and are used for elements that do not contain content.
Example: <img /> or <input />
These tags can include attributes like src or type.
Example of self-closing tags
<img src="image.jpg" alt="A descriptive image" />
<input type="text" placeholder="Enter your text" />
<div>
<p>This is a paragraph.</p>
</div>
Incorrect:
<div>
<p>This is a paragraph.</div>
</p>
The distinction between opening, closing, and self-closing tags is essential for writing valid and understandable HTML code. A good practice is to use an editor with HTML validation to avoid syntax errors.
<body><body> tag contains the main content of your HTML document, i.e., everything that is visible on the web page.<body>
<p>This is a paragraph.</p>
</body>
<hn><h1> to <h6> are title tags, h1 being the most important and h6 the least.<h1>Main Title</h1>
<h2>Secondary Title</h2>
<p><p> tag is used to define a paragraph.<p>This is an example paragraph.</p>
<a><a> tag defines a hyperlink.href: URL of the page the link leads to.<a href="https://www.example.com">Visit our site</a>
<img><img> tag is used to integrate images.src: The image URL.alt: Alternative text for the image.<img src="image.jpg" alt="Image description" />
<div><div> tag is a generic container for content flow.<div>
<p>A paragraph inside a div.</p>
</div>
href, src, alt.href="https://www.example.com", https://www.example.com is the value of the href attribute.