Make WordPress Core


Ignore:
Timestamp:
01/05/2026 04:02:03 PM (3 months ago)
Author:
jonsurrell
Message:

Scripts: Remove default attributes from tags.

SCRIPT, STYLE, and stylesheet LINK tags do not require a type attribute since the HTML5 standard was released in 2008. Removing the type attribute simplifies logic and normalizes the produced HTML content.

Developed in https://github.com/WordPress/wordpress-develop/pull/10664.

Follow-up to [61411], [46164].

Props jonsurrell, sabernhardt, westonruter.
Fixes #64428. See #59883, #64442.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme.php

    r61418 r61440  
    18941894    }
    18951895
    1896     $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
    1897 
    18981896    if ( ! $background && ! $color ) {
    18991897        if ( is_customize_preview() ) {
    1900             printf( '<style%s id="custom-background-css"></style>', $type_attr );
     1898            echo '<style id="custom-background-css"></style>';
    19011899        }
    19021900        return;
     
    19521950    }
    19531951
    1954     $processor = new WP_HTML_Tag_Processor( "<style{$type_attr} id=\"custom-background-css\"></style>" );
     1952    $processor = new WP_HTML_Tag_Processor( '<style id="custom-background-css"></style>' );
    19551953    $processor->next_tag();
    19561954
     
    19731971    $processor = new WP_HTML_Tag_Processor( '<style></style>' );
    19741972    $processor->next_tag();
    1975     if ( ! current_theme_supports( 'html5', 'style' ) ) {
    1976         $processor->set_attribute( 'type', 'text/css' );
    1977     }
    19781973    $processor->set_attribute( 'id', 'wp-custom-css' );
    19791974    $processor->set_modifiable_text( "\n{$styles}\n" );
     
    30073002        $classes = array_map( 'sanitize_html_class', $classes );
    30083003        $classes = '.' . implode( ', .', $classes );
    3009 
    3010         $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
    30113004        ?>
    30123005        <!-- Custom Logo: hide header text -->
    3013         <style id="custom-logo-css"<?php echo $type_attr; ?>>
     3006        <style id="custom-logo-css">
    30143007            <?php echo $classes; ?> {
    30153008                position: absolute;
Note: See TracChangeset for help on using the changeset viewer.