You can have conditional comments anywhere. Only the specified version of IE will parse the contents. In this case, where you have CSS in your conditional comment, it should be in your <head>
.
Also, it's not a good idea to use JS to insert a stylesheet. The user will see the unstyled (or incorrectly styled) content until the document.write
fires, and the css file loads. Insert with a server-side script such as PHP first.