Get HTML DOM with CSS
Posted
by 2x2p1p
on Stack Overflow
See other posts from Stack Overflow
or by 2x2p1p
Published on 2010-05-11T23:19:23Z
Indexed on
2010/05/11
23:34 UTC
Read the original article
Hit count: 291
CSS can apply styles in elements through one ID, class or pseudo-selector, but I would like to get the HTML tree, something like in javascript:
<script type = "text/javascript">
window.onload = function () {
var div = document.getElementsByTagName ("div");
div[0].style.backgroundColor = "gray";
div[0].style.padding = "20px";
}
</script>
So for example:
<style type = "text/css">
div[0] { /* Wrong but i tried :( */
background-color: gray;
padding: 20px;
}
</style>
<div >
<div>...</div>
</div>
I'm tired of assign IDs to millions and millions of elements; is there a way to do this?
© Stack Overflow or respective owner