Okay, I have a stylesheet called style.css with the following code:
And I have an index.html with this code:
As you can see, I'm trying to get the width of the <DIV> with the ID "content". However, when I run the webpage, it only shows an empty message box, meaning that it can't seem to retrieve the css width value of the <DIV>
However, I tried actually declaring the width style on the index.html with
and it seems to work this way
However, I don't want to do this as I want all style definitions enclosed in my .css file.
Can someone please help? Thanks!
Code:
#content {
width:50%;
padding:0;
}
And I have an index.html with this code:
Code:
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="content">
Hello world!
</div>
<script language="javascript" type="text/javascript">
alert(document.getElementById("content").style.width);
</script>
</body>
</html>
As you can see, I'm trying to get the width of the <DIV> with the ID "content". However, when I run the webpage, it only shows an empty message box, meaning that it can't seem to retrieve the css width value of the <DIV>
However, I tried actually declaring the width style on the index.html with
Code:
<div id="content" style="width:50%">
However, I don't want to do this as I want all style definitions enclosed in my .css file.
Can someone please help? Thanks!
Comment