Calling CSS in Javascript


#1

in HTML you can call CSS

<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<tr><td class="cssHere">Display</td></tr>

can you even call CSS in javascript?

document.writeln("<tr><td class="cssHere">" + Display + "</td></tr>");

if so how do you even call the "style.css"

thanks


#2

document.write('<style>#id { display:none }</style>');


#3

huh...

document.write('<style>#id { display:none }</style>');

what is #id
does this mean I can NOT call a .css file?


#4

Yes you can call a CSS link. Just put it in there in place of what I put.


#5

As an example, in your CSS page you might have:
.sml { font-size:12px; color:#F00; }

In your document you can write
document.writeln("<tr><td class="sml">" + Display + "</td></tr>");

and the text in Display will be 12px, red when the page renders.