validator
validator copied to clipboard
`rel` attribute (erroneously) valid on `pre` (and possibly other elements)
URL being validated or code to reproduce error:
<!doctype html>
<title>rel</title>
<pre rel=test></pre>
Expected result: The validator returns an error for rel on pre.
Actual result: No errors or warnings.
Rationale: I reviewed the specification again and per the attributes list, rel should be used with a, area, and link elements. Crossed-checked this against global attributes, of which rel is no part. Checked also on the pre element, where it doesn’t look like rel should be able to be used.
Unless I’m missing something, the validator should return an error here. (I didn’t check on other elements, but there may be issues around rel on other elements, too.)
Howdy Jens —
The checker includes full support for RDFa, and at https://www.w3.org/TR/html-rdfa/#extensions-to-the-html5-syntax the HTML+RDFa spec say this:
the following RDFa attributes are allowed on all elements in the HTML5 content model:
@vocab,@typeof,@property,@resource,@prefix,@content,@about,@rel,@rev,@datatype, and@inlist
And as far as how that relates to the core requirements in the HTML spec, at https://html.spec.whatwg.org/multipage/infrastructure.html#extensibility-2 the HTML spec explicitly provides a hook for other specs to override requirements:
When vendor-neutral extensions to this specification are needed, either this specification can be updated accordingly, or an extension specification can be written that overrides the requirements in this specification. When someone applying this specification to their activities decides that they will recognize the requirements of such an extension specification, it becomes an applicable specification for the purposes of conformance requirements in this specification.
So the HTML+RDFa spec is an extension specification that defines some new requirements that override some particular requirements in the HTML spec, and this checker recognizes those new requirements — and so for the purposes of this checker, the HTML+RDFa spec is an “applicable specification”.
Ah, got it. I didn’t make that connection to RDFa and extensions. Thanks for explaining, @sideshowbarker!
Is there any checking on the values of these attributes?
(Curious, but no need to keep this open then.)
Is there any checking on the values of these attributes?
https://github.com/validator/validator/blob/main/schema/html5/rdfa.rnc includes some microsyntax/datatype checking of certain values to ensure that they’re either an RDFa “term”, CURIE, “safe” CURIE or URI, and to check that the value of the prefix attribute follows the requirements in the spec.
Going ahead and closing this. But if there’s any reason for keeping it open, lemme know