• Hello,

    I’m using Polylang on a client website that got a grant from the government, and it has to be 100% compliant with W3’s accessibility standards. One of the requirements is to pass the test on https://validator.w3.org/nu/?doc=https%3A%2F%2Fpackmetal.eu%2F but we are getting an error that appears to be related to your plugin:

    Warning: The type attribute for the style element is not needed and should be omitted.
    From line 52, column 1; to line 52, column 23
    t=xml” />↩<style type=”text/css”>BODY .

    I tried to add this snippet to the functions.php file to get rid of the “type” attribute, but it didn’t work because the script is probably not added in the correct way through the “wp_enqueue_scripts” filter, therefore there is no way to remove it through the filters:

    <?php

    if ( ! function_exists( ‘prefix_remove_type_attr’ ) ) {

    /**
    * Remove ‘type’ Attribute of Scripts and Styles
    */
    function prefix_remove_type_attr( $tag ) {
    return preg_replace( “/type=[‘\”]text\/(javascript|css)[‘\”]/”, ”, $tag );
    }

    add_filter( ‘style_loader_tag’, ‘prefix_remove_type_attr’, 10 );
    add_filter( ‘script_loader_tag’, ‘prefix_remove_type_attr’, 10 );
    add_filter( ‘autoptimize_html_after_minify’, ‘prefix_remove_type_attr’, 10 ); // ‘Autoptimize’ plugin support

    }

    Can you please take a look at this and give me a workaround? I have already updated the plugin to the latest version but that didn’t solve the issue.

    Thanks.

    The page I need help with: [log in to see the link]

The topic ‘Type attribute causing accessibility error’ is closed to new replies.