HTML Tag Counter
Count lexical HTML start tags while ignoring comments, declarations, closing tags, and apparent tags inside raw-text elements.
Description
Start-tag counts measure lexical markup occurrences rather than the number of browser DOM elements.
Start-tag counts measure lexical markup occurrences rather than the number of browser DOM elements. Comments and raw-text contents should not count as tags.1
The returned values include Number of start tags. The How section below explains the calculation, input rules and interpretation.
When to use HTML Tag Counter
Use HTML Tag Counter when you need to evaluate the supplied records under the calculation and evidence rules below. No browser tree repair, implied elements, HTML validation or DOM count is produced.
Paste the requested source HTML or single start tag. Decide whether lexical source information meets your task before interpreting its output.
How to use HTML Tag Counter and understand its results
- Paste the requested source HTML or single start tag. Decide whether lexical source information meets your task before interpreting its output.
- Enter html using the field table and calculation rules, then run the tool.
- Read count. The explanation below defines the units, signs, ordering and any flags or placeholder values.
- If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
| Input field | Meaning | Value type; see rules below | Requirement |
|---|---|---|---|
| html | HTML source to scan. | string; maximum length: 1000000 | Required |
Paste HTML source. Scan quoted attribute values without ending a tag at an inner greater-than sign. Recognize valid start/end tags, comments and declarations; count only start tags, including void and self-closing forms. Suppress apparent tags inside script/style/textarea/title/xmp/iframe/noembed/noframes until the corresponding close. Empty source returns zero.2
count=number of scanner start tokens Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| count | Number of start tags. | integer; minimum: 0 |
{
"input": {
"html": "<p>Hello <b>world</b></p><!-- <i>ignored</i> --><script>\"<div>\"</script>"
},
"output": {
"count": 3
}
} Limitations and assumptions
No browser tree repair, implied elements, HTML validation or DOM count is produced.
Numeric inputs, where present, must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing fields without a declared default, extra fields, wrong value types and violations of the calculation rules are input errors.
Alternative or Complementary methods
Use HTML Attribute Parser: An HTML start tag has a name and attributes whose lexical spelling can differ from browser-decoded values. Duplicate attributes require an explicit retention rule. For a complementary task, use HTML Text Extractor: HTML source text differs from browser-rendered text. This lexical extractor joins text tokens while excluding script/style content and decoding a small reference set.
References
-
HTML Tag Counter — tool.io
-
HTML Attribute Parser — tool.io
Similar or alternative tools
- HTML Attribute Parser
An HTML start tag has a name and attributes whose lexical spelling can differ from browser-decoded values. Duplicate attributes require an explicit retention rule.
- HTML Text Extractor
HTML source text differs from browser-rendered text. This lexical extractor joins text tokens while excluding script/style content and decoding a small reference set.