Skip to main content
15 events
when toggle format what by license comment
Jun 23, 2011 at 18:10 comment added Ian Dunn @One Trick Pony, I think you're wrong, but I'm tired of arguing about it.
Jun 23, 2011 at 18:09 comment added Ian Dunn @mfields, that's a good point, but I prefer the enqueue_style approach.
Jun 23, 2011 at 17:01 comment added onetrickpony You didn't mention any objective reasons against this practice. Anyway it doesn't matter; I only see two options here: Always load CSS/scripts (optimize them for size), or conditional inline styles
Jun 23, 2011 at 16:51 comment added mfields make it filterable and any other plugin or theme can do as they like with it. If they configure the filter to return an empty string - nothing will be printed.
Jun 23, 2011 at 16:47 comment added Ian Dunn @mfields, if I do that then other theme/plugin developers can't replace the files with their own. It doesn't matter if the core does it, it's still a bad practice.
Jun 23, 2011 at 16:42 comment added mfields It's considered a bad practice but this is precisely what WordPress core's gallery shortcode does: Print a css block inline. It's a bit better than using the style attribute and works. My plugin that has a shortcode just prints the css to the head on every view. There's not a lot of it :)
Jun 23, 2011 at 16:11 comment added Ian Dunn I gave 4 reasons in my comment above...
Jun 23, 2011 at 15:51 comment added onetrickpony If you don't follow it blindly, then can you provide reasons why this practice is bad ?
Jun 23, 2011 at 15:49 comment added Ian Dunn @One Trick Pony Um... It means something to me. And it means something to every other developer that I respect. I don't follow it blindly, but it'd be rare for me to consider anything that breaks standards to be an acceptable answer.
Jun 23, 2011 at 15:43 comment added onetrickpony @EAMann. True, my mistake, I thought it would validate. Still, W3C validation means nothing...
Jun 23, 2011 at 15:41 comment added Ian Dunn Yeah, I know that's a possibility, but it's considered a bad practice. It could cause FOUC, force the browser to re-render the page and fail the W3C validator. It also won't work with wp_enqueue_style(), making it impossible for other theme/plugin developers to easily substitute their own script/styles.
Jun 23, 2011 at 15:36 comment added EAMann According to W3C's validation tool: <style type="text/css"> The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head". So inline styles (<element style="..."></element>) are valid, but inline <style> elements aren't.
Jun 23, 2011 at 15:32 comment added onetrickpony Inline CSS blocks are valid markup, even in XHTML from what I remember. There's no reason not to use them when you have no other acceptable alternative
Jun 23, 2011 at 15:29 comment added EAMann Loading CSS outside the <head> element isn't proper markup. True, validation is just a guideline, but if we're trying to stick to that guideline it makes loading the stylesheet within the shortcode output a bad idea.
Jun 23, 2011 at 15:22 history answered onetrickpony CC BY-SA 3.0