Forum Moderators: open
<script language="JavaScript" type="text/javascript">
<!--
document.write("<link rel=\"stylesheet\" href=\"style/style.css\">");
// -->
</script>
My question is: Why not just include the <link> element in the HTML code? What benefit is there to dynamically adding this element to the HTML document by means of script?
Thanks
The CSS being loaded is only of any use if Javascript is enabled, and would be counterproductive if Javascript is disabled. A layered presentation, for instance, would call on rules that position the content, and hide a large proportion of it. If javascript is off, then that sheet isn't loaded, the content isn't layered or hidden, but all in plain view instead.