Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#24499 closed enhancement (fixed)

Twenty Thirteen: Remove trailing slashes on void elements, remove type attribute from script

Reported by: retlehs's profile retlehs Owned by: lancewillett's profile lancewillett
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.6
Component: Bundled Theme Keywords: has-patch
Focuses: Cc:

Description

It'd be nice if Twenty Thirteen had these small changes made since it's using an HTML5 doctype. You can find a lot of discussions on the web talking about these two things - the general consensus is that it's best practice to avoid these patterns.

Remove trailing slashes

The XHTML-style closing slashes are optional and ideally should be removed from the <meta> and <link> elements.

http://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements

Remove type attribute from script

The type attribute gives the language of the script or format of the data. If the attribute is present, its value must be a valid MIME type. The charset parameter must not be specified. The default, which is used if the attribute is absent, is "text/javascript".

http://www.w3.org/html/wg/drafts/html/master/scripting-1.html#the-script-element


Current code:

<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
    <meta name="viewport" content="width=device-width" />
    <title><?php wp_title( '|', true, 'right' ); ?></title>
    <link rel="profile" href="http://gmpg.org/xfn/11" />
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    <!--[if lt IE 9]>
    <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
    <![endif]-->
    <?php wp_head(); ?>
</head>

Proposed:

<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width">
    <title><?php wp_title( '|', true, 'right' ); ?></title>
    <link rel="profile" href="http://gmpg.org/xfn/11">
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    <!--[if lt IE 9]>
    <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js"></script>
    <![endif]-->
    <?php wp_head(); ?>
</head>

Attachments (1)

twentythirteen-remove-trailing-slashes-and-type-attr.patch (1005 bytes) - added by retlehs 12 years ago.

Download all attachments as: .zip

Change History (6)

#1 @lancewillett
12 years ago

  • Keywords needs-patch added; dev-feedback removed
  • Milestone changed from Awaiting Review to 3.6

Thanks for bringing this up.

Totally agree on the script "type" removal.

For the void element final forward slash, old habits die hard. :)

We're *still* migrating (both in practice and content) from XHTML land to HTML land, and it'll be a long time before we're there completely because of how much content is already published with the older XML-like syntax.

As you point out, all the specs (WHATWG, W3C) say that the slash is optional and has no effect on void elements. So, while not harmful, it's cruft and can be removed safely.

Some additional reading:

#2 @retlehs
12 years ago

  • Cc retlehs added
  • Keywords has-patch added; needs-patch removed

Added patch

#3 @lancewillett
12 years ago

  • Owner set to lancewillett
  • Resolution set to fixed
  • Status changed from new to closed

In 24412:

Twenty Thirteen markup cleanup:

  • Remove trailing slashes on void elements such as meta and link
  • Remove type attribute from script element

Props retlehs, fixes #24499.

#4 @alexvorn2
12 years ago

what about other themes? and theme-compat header.php file?

#5 @lancewillett
11 years ago

In 26672:

Twenty Fourteen: remove trailing slashes on void elements such as meta and link, and remove type attribute from script element. See #24499.

Note: See TracTickets for help on using tickets.