Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Welcome to Topic 1.4! 🧱
In the previous lessons, you got introduced to HTML and set up VS Code on your computer. Now it is time to understand the most important concept in all of web development: HTML Elements.
Every webpage you see on the internet—every headline, paragraph, picture, button, and link—is an HTML Element. If a webpage is a brick building, HTML elements are the individual bricks used to build it.
An HTML Element is everything from the starting tag to the ending tag, including the content inside it.
Let us use a simple real-life example: A Sandwich! 🥪
How data and code flow step-by-step
<p>).I love web development!)./ (e.g., </p>).Many students use the words "Tag" and "Element" as if they mean the exact same thing. But there is a clear difference:
| Term | What It Means | Example |
|---|---|---|
| Tag | Just the label inside the angle brackets < > | <p> (opening tag) or </p> (closing tag) |
| Element | The complete combination of start tag + content + end tag | <p>Hello Students</p> |
HTML has two main types of elements:
These elements contain text or other tags inside them. They must have both an opening tag and a closing tag:
Some elements do not contain any text inside them. Because they have no content, they do not need a closing tag!
Here are the most common empty elements you will use:
| Tag | Full Name | What It Does | Example |
|---|---|---|---|
<br> | Break | Moves text to the next line (like pressing Enter) | <p>Line 1<br>Line 2</p> |
<hr> | Horizontal Rule | Draws a straight horizontal divider line across the page | <hr> |
<img> | Image | Embeds a picture on the page | <img src="photo.jpg" alt="Nature"> |
<input> | Input Field | Creates a box for typing text or passwords | <input type="text"> |
<br> or <br />. Both work identically in all browsers, but simple <br> is standard and easier to write.In HTML, you can place elements inside other elements. This is called Nesting.
Think of nesting like your School Bag:
<body>).<p>).<b>).In this example:
<p> element wraps the entire sentence.<b> element is nested inside <p> to make the words "MSK Institute" appear bold.Tags must always be closed in the reverse order of how they were opened. The tag that opens last must close first!
(Here <b> opened last, so </b> closed first. Then </i>, and finally </p>.)
(Here <b> opened inside <i>, but <i> was closed before <b>. This confuses browsers!)
HTML is case-insensitive, meaning <P>, <p>, and <P> all work in browsers.
However, international web standards (W3C) strongly recommend writing all HTML tags in lowercase (small letters):
<p>, <h1>, <div><P>, <H1>, <DIV>Writing in lowercase makes your code clean, professional, and easy to read.
Always remember: The inner tag must close before the outer tag closes.
<p> or </p>, while an Element is the complete bundle.<h1>...</h1>, <p>...</p>).<br>, <hr>, <img>).Test your understanding with these multiple-choice questions:
index.html file.<body>, create:<h1> heading with your school's name.<p> paragraph describing your favorite subject.<b> inside the paragraph to make your subject bold.<br> to split the sentence into two separate lines.<hr> horizontal divider line below it.Ctrl + S) and check your live page in the browser! 🚀In the next lesson, we will continue your web development journey with Attributes (Introduction).
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| VS-Code Setup | Attributes |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.