An HTML element is a fundamental building block of a webpage. It consists of a start tag, content, and an end tag. The start tag defines the element and its attributes, while the end tag marks the end of the element.
HTML elements are typically written as:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
HTML Elements Example
</head>
<body>
<tagname>Content goes here</tagname>
</body>
</html>
Content goes here
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome To My Elements Page</title>
</head>
<body>
<p>This is a paragraph</p>
</body>
</html>
This is a paragraph
The above example defines a <p>
(paragraph) element containing the text "This is a paragraph".
<a>
Element (Anchor Tag)The anchor element is used to create hyperlinks:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome To My Elements Page</title>
</head>
<body>
<a href="http://aitaurangabad.com/">Visit AitAurangabad</a>
</body>
</html>
Visit AitAurangabad
This creates a clickable link that navigates to the specified URL.
<img>
Element (Image)The image element is used to display images:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome To My Elements Page</title>
</head>
<body>
<img src="Birds.jpg" alt="Description">
</body>
</html>
This example displays an image from the specified source with an alternative description.
<ul>
and <li>
Elements (Unordered List)Unordered lists consist of list items:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome To My Elements Page</title>
</head>
<body>
<ul>
<li>Mango 1</li>
<li>Grapes 2</li>
<li>Apple 3</li>
</ul>
</body>
</html>
- Mango 1
- Grapes 2
- Apple 3
This creates an unordered list with three items.
<form>
Element (Form)The <form>
element is used to collect user input:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome To My Elements Page</title>
</head>
<body>
<form action="/submit">
<label for="name">Name:</label>
<input type="text" id="name">
<input type="submit" value="Submit">
</form>
</body>
</html>
This creates a form where the user can input their name and submit it.
<div>
Element (Division)The <div>
element is a container used for grouping content:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome To My Elements Page</title>
</head>
<body>
<div>
<h1>Header</h1>
<p>This is a paragraph inside a div.</p>
</div>
</body>
</html>
Header
This is a paragraph inside a div.
This example uses the <div>
element to group a header and a paragraph.
HTML elements are the building blocks of web pages, and they define the structure and content of a webpage. Understanding these elements will help you create more organized and functional HTML documents.