Explain HTML Elements
HTML (HyperText Markup Language) is the standard language used to create and design webpages. HTML elements are the building blocks of HTML, and they consist of a start tag, content, and an end tag. Here’s a breakdown of HTML elements with examples:
Basic Structure
An HTML element generally follows this structure:
<tagname>Content</tagname>
Examples
-
Paragraph Element (
<p>):- Purpose: Represents a block of text.
- Example:
<p>This is a paragraph.</p>
-
Heading Elements (
<h1>,<h2>,<h3>,<h4>,<h5>,<h6>):- Purpose: Define headings, with
<h1>being the highest level and<h6>the lowest. - Example:
<h1>This is a heading level 1</h1> <h2>This is a heading level 2</h2>
- Purpose: Define headings, with
-
Anchor Element (
<a>):- Purpose: Creates hyperlinks to other webpages or resources.
- Example:
<a href="https://www.example.com">Visit Example.com</a>
-
Image Element (
<img>):- Purpose: Embeds images in a webpage.
- Attributes:
src(source URL of the image),alt(alternative text for the image) - Example:
<img src="image.jpg" alt="A description of the image">
-
List Elements (
<ul>,<ol>,<li>):- Purpose: Represent lists.
<ul>creates an unordered (bulleted) list, while<ol>creates an ordered (numbered) list. - Example:
<ul> <li>Item 1</li> <li>Item 2</li> </ul> <ol> <li>First item</li> <li>Second item</li> </ol>
- Purpose: Represent lists.
-
Div Element (
<div>):- Purpose: A generic container used to group content for styling or scripting.
- Example:
<div class="container"> <p>This is inside a div element.</p> </div>
-
Span Element (
<span>):- Purpose: A generic inline container used to style a part of text or content.
- Example:
<p>This is <span style="color: red;">red text</span> in a paragraph.</p>
-
Form Element (
<form>):- Purpose: Contains interactive controls for user input.
- Example:
<form action="/submit-form" method="post"> <label for="name">Name:</label> <input type="text" id="name" name="name"> <input type="submit" value="Submit"> </form>
These elements can be combined and nested to create complex web pages. Each has its specific use and attributes that enhance functionality and styling.
Your Feedback
Help us improve by sharing your thoughts
Online Learner helps developers master programming, database concepts, interview preparation, and real-world implementation through structured learning paths.
Quick Links
© 2023 - 2026 OnlineLearner.in | All Rights Reserved.
