Introduction:
In markup languages (like HTML or XML),
a tag is a piece of code used to define an element,
Instructing the browser or system "how to interpret and structure content" rather than "how to present it visually."
Structure
An HTML/XML element typically consists of three parts:
- Opening Tag (<tagname>): Marks the start of an element and can contain attributes.
- Content: The text, image, or other elements nested inside.
- Closing Tag (</tagname>): Marks the end of an element, denoted by a forward slash.
- <p class="intro"> = Opening tag with attribute (class="intro")
- Hello World = Content
- </p> = Closing tag
Example: <p class="intro">Hello World</p>
Self-Closing / Void Tags:
Tags that do not wrap content do not require a closing tag (e.g., <img />, <br />, <input />).
Rules
-
Proper Nesting: Tags must be closed in the reverse order they were opened (First In, Last Out).
- Correct: <b><i>Text</i></b>
- Incorrect: <b><i>Text</b></i>
- Lowercase Conventions: Writing all tag names and attributes in lowercase (e.g., <div>, not <DIV>).
- Quote Attribute Values: Attributes inside an opening tag should always have their values enclosed in quotation marks (e.g., href="[https://example.com](https://example.com)").
Tags should only be used to define structure and semantics, not presentation (styling should be handled via CSS).
No comments:
Post a Comment
Thank you to visit Bapi's Page.