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

  1. Paste the requested source HTML or single start tag. Decide whether lexical source information meets your task before interpreting its output.
  2. Enter tag using the field table and calculation rules, then run the tool.
  3. Read name, attributes. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. 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 fieldMeaningValue type; see rules belowRequirement
tagOne complete HTML start tag.string; maximum length: 1000000Required

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 fieldMeaningValue type
nameLowercase tag name.string; maximum length: 1000000
attributesAttributes with raw values in source order.list of object; minimum entries: 0; maximum entries: 100000
attributes[].nameField in attributes recordstring; maximum length: 1000000
attributes[].valueField in attributes recordstring; maximum length: 1000000
json
{
  "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

  1. HTML Attribute Parser — tool.io

  2. 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.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies