here are some of the most commonly used HTML elements, along with a brief description and an example of how to use them in an HTML page:
<html>
- The HTML document starts and ends with this tag. This tag is used to enclose all the other HTML tags within it. Example:
php<!DOCTYPE html>
<html>
<head>
<title>My Webpage</title>
</head>
<body>
<h1>Welcome to my webpage</h1>
<p>This is my first HTML page</p>
</body>
</html>
<head>
- This tag is used to define the head section of the HTML document. It contains information such as the title, meta tags, links to CSS files, etc. Example:
php<head>
<title>My Webpage</title>
<meta name="description" content="A description of my webpage">
<link rel="stylesheet" href="styles.css">
</head>
<title>
- This tag is used to define the title of the HTML document, which appears in the browser's title bar. Example:
php<head>
<title>My Webpage</title>
</head>
<body>
- This tag is used to define the body section of the HTML document. It contains all the content that is displayed on the webpage. Example:
css<body>
<h1>Welcome to my webpage</h1>
<p>This is my first HTML page</p>
</body>
<h1>
to<h6>
- These tags are used to define headings of different levels.<h1>
is the highest level, and<h6>
is the lowest level. Example:
css<h1>Main Heading</h1>
<h2>Sub Heading</h2>
<h3>Sub-Sub Heading</h3>
<p>
- This tag is used to define paragraphs of text. Example:
css<p>This is a paragraph of text.</p>
<a>
- This tag is used to define hyperlinks. It can be used to link to other webpages, or to specific sections within the same webpage. Example:
php<a href="https://www.google.com">Visit Google</a>
<img>
- This tag is used to display images on the webpage. Example:
php<img src="image.jpg" alt="An image">
<ul>
and<li>
- These tags are used to create unordered lists.<ul>
defines the list, and<li>
defines each item in the list. Example:
css<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<ol>
and<li>
- These tags are used to create ordered lists.<ol>
defines the list, and<li>
defines each item in the list. Example:
css<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
<table>
- This tag is used to create tables on the webpage. Example:
css<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<form>
- This tag is used to create forms, which allow users to input data.
Example:
php<form>
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br><br>
<input type="submit" value="Submit">
</form>
<input>
- This tag is used to create input fields in a form. The type
attribute is used to specify the type of input field (text, email, password, etc.).
Example:
python<input type="text" id="name" name="name">
<input type="email" id="email" name="email">
<input type="password" id="password" name="password">
<button>
- This tag is used to create buttons on the webpage.
Example:
css<button>Click me</button>
<div>
- This tag is used to group elements together into a block-level container. It is often used to apply CSS styles to a group of elements.
Example:
css<div class="container">
<h1>Main Heading</h1>
<p>This is a paragraph of text.</p>
</div>
<span>
- This tag is used to group inline elements together. It is often used to apply CSS styles to a group of inline elements.
Example:
css<p>My favorite color is <span style="color: blue;">blue</span>.</p>
<br>
- This tag is used to create a line break (i.e., move to the next line).
Example:
php<p>This is the first line.<br>This is the second line.</p>
<hr>
- This tag is used to create a horizontal line.
Example:
php<p>This is some text.</p>
<hr>
<p>This is some more text.</p>
<meta>
- This tag is used to include metadata in the HTML document, such as keywords, description, and author information.
Example:
php<meta name="keywords" content="HTML, CSS, JavaScript">
<meta name="description" content="This is a description of my webpage.">
<meta name="author" content="John Doe">
<script>
- This tag is used to include JavaScript code in the HTML document.
Example:
php<script>
alert("Hello, world!");
</script>
These are just a few examples of the many HTML elements available. There are many more tags and attributes that can be used to create complex and interactive webpages.