I am using a CMS and apparently it has a bug that will not allow me to add any content to the <head>
of a blog post. It inserts everything into the body which in most cases that works okay but in an instance of code like this:
<style type="text/css">
.slideshow img { display: none }
.slideshow img.first { display: block }
</style>
Will that type of code run if put inside the <body>
tag in all major browsers? (IE8+, Firefox, Chrome, and Safari.) Normally that is always in the <head>
of the page.
Note: This appears to work in FF 15 but I am not sure of other browsers.
Having style tags in the body is invalid code.
Every browser will try to use the invalid code in a way that makes sense. Some browsers seem to use the style rules anyway, but you can't rely on that being the behaviour of all current and future browsers. Another behaviour that would also make perfect sense would be to ignore the invalid style tag.
Note that even within the same browser the behaviour can differ depending on whether the page is rendered in standards compliance mode or quirks mode. In standards compliance mode (which is the preferred one) browsers tend to be more strict and ignore invalid code rather than try to guess what the author intended with the code.
In HTML5 you can use style tags in the body element. In any older browsers that are not aware of HTML5, or if you don't have a HTML5 doctype, it's still invalid code.