[wp-trac] [WordPress Trac] #59432: Compliant with W3C coding standards

WordPress Trac noreply at wordpress.org
Sun Sep 24 00:28:09 UTC 2023


#59432: Compliant with W3C coding standards
-------------------------+-------------------------------
 Reporter:  agypten      |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  General      |     Version:  6.3.1
 Severity:  minor        |  Resolution:
 Keywords:               |     Focuses:  coding-standards
-------------------------+-------------------------------
Changes (by sabernhardt):

 * focuses:   => coding-standards


Old description:

> When validating any WordPress site, warnings appear:
> 1. Trailing slash on void elements has no effect and interacts badly with
> unquoted attribute values. Example: <meta name='robots' content='noindex,
> nofollow'/>
> <link rel="alternate" href="https://samesite.com/" hreflang="US"/>
> Also in tags img, button etc
> 2. The type attribute for the style element is not needed and should be
> omitted.
> Example: <style id='global-styles-inline-css' type='text/css'>
> 3.  The type attribute is unnecessary for JavaScript resources.
> Example: <script type='text/javascript' ...>
>
> A suggestion for improvement is to fix these warnings by removing
> attributes and symbols that are no longer needed. This will reduce the
> amount of code and relieve SEO optimizers from headaches).

New description:

 When validating any WordPress site, warnings appear:
 1. Trailing slash on void elements has no effect and interacts badly with
 unquoted attribute values. Example: `<meta name='robots' content='noindex,
 nofollow'/>`
 `<link rel="alternate" href="https://samesite.com/" hreflang="en-US"/>`
 Also in tags img, button etc
 2. The type attribute for the style element is not needed and should be
 omitted.
 Example: `<style id='global-styles-inline-css' type='text/css'>`
 3.  The type attribute is unnecessary for JavaScript resources.
 Example: `<script type='text/javascript' ...>`

 A suggestion for improvement is to fix these warnings by removing
 attributes and symbols that are no longer needed. This will reduce the
 amount of code and relieve SEO optimizers from headaches).

--

Comment:

 Unless/until the handbook changes, [https://developer.wordpress.org
 /coding-standards/wordpress-coding-standards/html/#self-closing-elements
 self-closing elements] should have a slash with the space before it.

 Also, if the `type` attribute is used on style tags such as global styles,
 the active theme probably needs to declare
 [https://developer.wordpress.org/reference/functions/add_theme_support/#html5
 HTML5 'style' and 'script' support] to remove those. (Block-based themes
 remove the `type` automatically.)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59432#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list