Support » Fixing WordPress » <link rel='stylesheet' being converted to inline css

  • Resolved flymike

    (@flymike)


    I have a plugin whose shortcode implementation outputs <link rel='stylesheet' type='text/css' href='...css' /> (actual href excluded here). In other words, outputting a link to a stylesheet.

    This works perfectly on my development site but, on the production site, something is imbedding the CSS file’s content so that the link is removed and becomes <style>css file content</style>

    Any ideas on how to debug this problem?

    It’s not practical to sequentially disable each plugin on the productions site, as there are more than 40 plugins.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    This may be a plugin or theme conflict. Please attempt to disable all plugins, and use one of the default (Twenty*) themes. If the problem goes away, enable them one by one to identify the source of your troubles.

    If you can install plugins, install “Health Check”: https://wordpress.org/plugins/health-check/ On the troubleshooting tab, you can click the button to disable all plugins and change the theme for you, while you’re still logged in,
    without affecting normal visitors to your site. You can then use its admin bar menu to turn on/off plugins and themes one at a time.

    Thread Starter flymike

    (@flymike)

    Answering my own question…
    It is not some WordPress plugin – but Chrome (80.0.3987.87) which is converting my linked stylesheet to inline style.

    And I assume this is because I have the linked stylesheet within the HTML document body, instead of within the head. This was not supported at all in HTML 4, but is allowed, though not recommended, in HTML 5.

    Firefox 72.0.2 appears to fully support linked stylesheets within the body, but Chrome converts to inline.

    I worked around the problem by using <style>@import url("my-stylesheet");</style>

    And, finally – it mattered – because I was using @media to control style when printing, and @media is not available for inline styles.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    >> And, finally – it mattered – because I was using @media to control style when printing, and @media is not available for inline styles. <<

    Thanks. Someday, if I remember that, it might save me some considerable grief. HOWEVER, your plugin should be enqueuing stylesheets correctly, which puts them in the header.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘<link rel='stylesheet' being converted to inline css’ is closed to new replies.