Unexpected elements in the HTML element

Description

Rule ID: elements-not-allowed-in-head

This rule verifies if there are elements that shouldn’t be in the <head> section.

    Context

    <head> section contains elements that provide information of how the document should be perceived, and rendered, by web technologies. e.g. browsers, search engines, bots, screen readers, etc.

    Non-valid pages rely on the browser to auto-correct your code, and each browser does this differently. If your code is valid, the browser has to do less processing as it doesn’t have to correct any code, therefore, the page will render faster and be more predictable.

    In order to make the code accurately processed and rendered, it is recommended to have only valid HTML elements/tags in the <head> section.

    Following elements are allowed to be in the <head> section:

    • <title>
    • <base>
    • <link>
    • <style>
    • <meta>
    • <script>
    • <noscript>
    • <template>

    All other elements/tags are perceived as non-valid.

    How to fix it

    The rule passes when only following elements/tags are specified in the <head> section:

    • <title>
    • <base>
    • <link>
    • <style>
    • <meta>
    • <script>
    • <noscript>
    • <template>

    Techniques

    Not Applicable