Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Which of the following is not a valid HTML tag: h1, H, h2, h3?
HTML uses specific tags to structure and organize content on web pages. Understanding which tags are valid and which are not is crucial for proper HTML development. The question asks about the validity of four potential heading tags: h1, H, h2, and h3.
HTML Tag Syntax
HTML tags follow a specific syntax structure enclosed in angle brackets
<tagname>Content</tagname>
Valid HTML tags must have defined names in the HTML specification. Tag names are case-insensitive, meaning <h1> and <H1> are equivalent.
HTML Heading Tags
HTML provides six levels of heading tags to create a hierarchical structure for content. These tags range from <h1> (most important) to <h6> (least important).
Valid Heading Tags
The following are all valid HTML heading tags
<h1>The primary heading, typically used once per page<h2>Secondary headings for major sections<h3>Sub-headings within h2 sections<h4>Further subdivision of content<h5>Fifth-level headings<h6>Smallest heading level
Analysis of the Given Options
Let us examine each of the four options provided
| Tag | Validity | Explanation |
|---|---|---|
<h1> |
Valid | Standard first-level heading tag |
<H> |
Invalid | Not defined in HTML specification |
<h2> |
Valid | Standard second-level heading tag |
<h3> |
Valid | Standard third-level heading tag |
Example Valid Heading Tags
Following example demonstrates the proper usage of valid heading tags
<!DOCTYPE html> <html> <head> <title>Valid HTML Heading Tags</title> </head> <body style="font-family: Arial, sans-serif; padding: 20px;"> <h1>Main Title (h1)</h1> <h2>Section Heading (h2)</h2> <h3>Subsection Heading (h3)</h3> <p>Regular paragraph text for comparison.</p> </body> </html>
The output shows the hierarchical structure with decreasing font sizes
Main Title (h1) (largest, bold) Section Heading (h2) (medium-large, bold) Subsection Heading (h3) (medium, bold) Regular paragraph text for comparison. (normal size)
Example Invalid Tag Demonstration
Following example shows what happens when using an invalid tag like <H>
<!DOCTYPE html> <html> <head> <title>Invalid Tag Example</title> </head> <body style="font-family: Arial, sans-serif; padding: 20px;"> <h1>Valid h1 heading</h1> <H>Invalid H tag</H> <h2>Valid h2 heading</h2> </body> </html>
The invalid <H> tag renders as plain text without any heading formatting
Valid h1 heading (large, bold heading) Invalid H tag (normal text, no special formatting) Valid h2 heading (medium-large, bold heading)
Why <H> is Invalid
The <H> tag is invalid because
Not in HTML specification HTML defines only
<h1>through<h6>as valid heading tagsMissing level number Heading tags require a number (1-6) to indicate their hierarchical level
No semantic meaning Browsers and assistive technologies don't recognize
<H>as a heading elementNo default styling Unlike valid heading tags,
<H>receives no special formatting
Best Practices for Heading Tags
When using heading tags, follow these guidelines
Use only one
<h1>tag per page for the main titleFollow hierarchical order (don't skip from
<h1>to<h3>)Use headings to create logical content structure, not just for styling
Keep heading text concise and descriptive
Conclusion
Among the given options (h1, H, h2, h3), the <H> tag is not valid HTML. HTML only recognizes numbered heading tags from <h1> to <h6>, each serving a specific hierarchical purpose in document structure. The <H> tag lacks the required level number and is not defined in the HTML specification.
