In HTML, a tag is a keyword written inside angle brackets (< >).
Tags tell the browser what to do with the content.
Most tags come in pairs:
<p></p> (with a / before the tag name)Example:
<p>This is a paragraph.</p>
<p> = opening tag</p> = closing tagπ Tags = Instructions to the browser.
An element is the combination of: π Start tag + Content + End tag
Example:
<h1>Hello, World!</h1>
<h1>Hello, World!</h1><h1>Hello, World!</h1>Container Elements
Have both an opening and closing tag.
They wrap content.
Example:
<p>This is a container element.</p>
Empty Elements
Do not have closing tags.
They are used for standalone tasks.
Examples:
<br> β line break<hr> β horizontal line<img> β insert an imageπ Remember: All empty elements are tags, but not all tags are empty elements.
Attributes provide extra information about an element.
They are always written in the opening tag.
Attributes follow this format:
attributeName="value"
Example:
<p align="center">This text is centered.</p>
align="center" is an attribute.π Think of attributes as "settings" for tags.
<p> β Paragraph<p align="right">This is a right-aligned paragraph.</p>
<p>align="right"<img> β Image<img src="flower.jpg" alt="A red flower" width="200" height="150" />
Attributes:
src β location of imagealt β alternate text (important for accessibility)width, height β dimensions<a> β Link<a href="https://www.cbse.gov.in" target="_blank">Visit CBSE Website</a>
Attributes:
href β link addresstarget="_blank" β opens link in a new tab<body> β Background<body bgcolor="lightblue"></body>
bgcolor (background color)β Quick Recap for You:
<p>)src, alt, href)