- HTML: HyperText Markup Language
- It is the skeleton of a webpage.
- Markup: Using annotations or tags to structure content.
- It is the basic building block of a website.
- Describes the structure and content of a webpage.
- Enables browsers to render web content (HTML document → Browser → Webpage).
- Combined with CSS (appearance) and JavaScript (functionality), it forms a Full-Stack Application.
- Tags tell the browser how to render different elements.
- Tags have two main types:
- Opening tag:
<h1>
- Closing tag:
</h1>
- Content: Text or elements between the opening and closing tags.
- Opening tag:
Example:
<h1>Namaste Duniya</h1>
<h1>
: Opening TagNamaste Duniya
: Content</h1>
: Closing Tag
Take up the full width of their container.
Examples:
<p>
(Paragraph)<h1>
(Heading)<ul>
<ol>
(Lists)<article>
<section>
Take up only as much width as necessary.
Examples:
<strong>
<a>
(Link)<em>
Do not require a closing tag.
Examples:
<br/>
<img/>
<input/>
- Ordered List: Items with numbers or letters.
<ol> <li>Item 1</li> <li>Item 2</li> </ol>
- Unordered List: Items with bullets.
<ul> <li>Item A</li> <li>Item B</li> </ul>
- Description List: Describes terms or items.
<dl> <dt>HTML</dt> <dd>HyperText Markup Language</dd> </dl>
Attributes provide additional information about an element and are declared in the opening tag.
src
: Used in<img>
to specify the image source.href
: Used in<a>
to specify the link.id
: Unique identifier for an element.class
: Specifies a class for an element (used in CSS).
Example:
<img src="tofu.jpeg" alt="Tofu" width="100" height="100">
<div id="Ramesh">This is a DIV tag</div>
<!DOCTYPE html>
: Declares the document as HTML5.<html>
: Root tag of an HTML document.- Example:
<html lang="en">
(Specifies the language of the document).
- Example:
<head>
: Contains metadata, title, and links to external resources.- Example:
<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head>
- Example:
<body>
: Contains the visible content of the webpage.
Meta tags store information about the website (metadata).
Examples:
<meta charset="UTF-8">
(Specifies character encoding).<meta name="viewport" content="width=device-width, initial-scale=1.0">
(Responsive design).
- What happens when you close an empty tag?
What happens when you close an empty tag?
If you close an empty tag (e.g., <br>
, <img>
, <input>
), it will have no negative effect in modern HTML.
-
Valid Syntax:
Empty tags can be written in two ways:- Without a closing slash:
<br> <img src="image.jpg" alt="Image">
- With a self-closing slash (optional in HTML5):
<br/> <img src="image.jpg" alt="Image"/>
- Without a closing slash:
-
Impact:
Browsers interpret both styles the same way. The closing slash (/
) is optional in HTML5 but required in older XHTML documents.
Closing an empty tag will not cause errors, but it is unnecessary in HTML5.