HTML Attribute Parser
Lexically parse one HTML start tag into its lowercase name and attributes, retaining raw character references and the first duplicate attribute.
Description
An HTML start tag has a name and attributes whose lexical spelling can differ from browser-decoded values.
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.1
The returned values include Lowercase tag name, Attributes with raw values in source order. The How section below explains the calculation, input rules and interpretation.
When to use HTML Attribute Parser
Use HTML Attribute Parser when you need to evaluate the supplied records under the calculation and evidence rules below. No DOM repair, attribute semantics, character-reference decoding or sanitization is performed. An unquoted trailing slash may be part of its value.
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 Attribute Parser 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 tag using the field table and calculation rules, then run the tool.
- Read name, attributes. 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 |
|---|---|---|---|
| tag | One complete HTML start tag. | string; maximum length: 1000000 | Required |
Paste exactly one complete start tag without surrounding whitespace. Parse an ASCII-letter initial tag name and whitespace-separated attributes. Lowercase names, accept quoted/unquoted/boolean forms, represent boolean value as empty string and retain first duplicate in source order. Keep character references raw. Require complete closing greater-than or slash-greater-than syntax.2
name=lowercase tag name; attributes=first occurrence by lowercase name Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| name | Lowercase tag name. | string; maximum length: 1000000 |
| attributes | Attributes with raw values in source order. | list of object; minimum entries: 0; maximum entries: 100000 |
| attributes[].name | Field in attributes record | string; maximum length: 1000000 |
| attributes[].value | Field in attributes record | string; maximum length: 1000000 |
{
"input": {
"tag": "<INPUT disabled value=\"a > b\" DATA-ID=42>"
},
"output": {
"name": "input",
"attributes": [
{
"name": "disabled",
"value": ""
},
{
"name": "value",
"value": "a > b"
},
{
"name": "data-id",
"value": "42"
}
]
}
} Limitations and assumptions
No DOM repair, attribute semantics, character-reference decoding or sanitization is performed. An unquoted trailing slash may be part of its value.
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 Tag Counter: 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. 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 Attribute Parser — tool.io
-
HTML Tag Counter — tool.io
Similar or alternative tools
- HTML Tag Counter
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.
- 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.