How do I use document.write with my stylesheet? For example, I want to use div, table and caption in a sepearte stylesheet and reference it in the document.write function in my HTML file.
Please consider the following stylesheet:
.div {
width:auto;
margin;10px;
}
.table {
background-color:purple;
border:1px solid
border-spacing:1px
border-collapse:separate;
padding:35px;
}
.caption {
background-color:purple;
}
Then I want to use these classes in the document.write() function in my HTML document:
<head> <link rel="stylehseet" href="style/myStyle.css"></head>
<body>
<script Language="JavaScript">
document.write('<div style="width:auto; margin:10px;">\
<table style="border="1" cellspacing="1" cellpadding="35">\
<caption style="background-color:purple;"> Table </caption>')
</script>
</body>
Instead of having the style defintions in the HTML file, how can I put the defintions in the CSS file and reference it in the HTML?
How do I combine forces, so to speak?
document.write('<div class="div">');? It will write a div that has that class. So your CSS will apply to it.