Skip to content

W3 Validator reports error for <link> with as attribute #901

Closed

Description

@iamkumaran

Bug report

Describe the bug

W3 validator reports error for the following tag,
<link href="/css/0919b1814a0e43ed7c9049ed6289f912a857a8b8a.cbb3cd6b.chunk.css" rel="prefetch" as="style">↩

To Reproduce

Go to https://validator.w3.org/#validate_by_input and paste the following code.

<head>
  <link href="/detail.js" rel="prefetch" as="script">
  <link href="/css/fbf7c3fcfcd81a51d0fbc055546483b038d3f696.2a2f6965.chunk.css" rel="prefetch" as="style">
  <link href="/chunks/fbf7c3fcfcd81a51d0fbc055546483b038d3f696.6568f0b4d67c968bdfc9.js" rel="prefetch" as="script">
  <link href="/chunks/ab377f30981d503665256a0af9ae1bab719f9341.66f8f60167be674f8392.js" rel="prefetch" as="script">
  <link href="/css/c965037ac80c17d285bafbec9ba17a6ff6120a0a.9d207964.chunk.css" rel="prefetch" as="style">
  <link href="/chunks/c965037ac80c17d285bafbec9ba17a6ff6120a0a.7ac29a0deaac58ac9e61.js" rel="prefetch" as="script">
</head>

You will start seeing the errors like

"A link element with an as attribute must have a rel attribute that contains the value preload."

Expected behavior

There should be no error. As per W3.org as is permitted in rel="prefetch".
https://www.w3.org/TR/resource-hints/#prefetch

Screenshot attached,
image

Activity

  1. sideshowbarker commented on Jan 22, 2020

    @sideshowbarker
    Member

    The relevant requirements are stated in the HTML spec, here:

    https://html.spec.whatwg.org/multipage/semantics.html#attr-link-as

    The as attribute specifies the potential destination for a preload request for the resource given by the href attribute. It is an enumerated attribute. Each potential destination is a keyword for this attribute, mapping to a state of the same name. The attribute must be specified on link elements that have a rel attribute that contains the preload keyword. It may be specified on link elements that have a rel attribute that contains the modulepreload keyword; in such cases it must have a value which is a script-like destination. For other link elements, it must not be specified.

    A link element with rel=prefetch is an other link elements case, covered in the last sentence of the above paragraph. So the HTML spec say that as must not be specified for rel=prefetch link elements.

    There should be no error. As per W3.org as is permitted in rel="prefetch".
    https://www.w3.org/TR/resource-hints/#prefetch

    The requirement needs to be stated in the HTML spect. To get it added to the HTML spec, I suggest raising an issue at https://github.com/whatwg/html/issues — or else, raising an issue at https://github.com/w3c/resource-hints/issues, to suggest to the Resource Hints spec editor that they port that requirement from the Resource Hints spec to the HTML spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions