Jump to content
  • Advertisement
Sign in to follow this  

[web] Div not working?

This topic is 4959 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I dont know why but my main div isn't working at all. Here is my source. mycss.css
a.nav{text-decoration:none;}
a.nav:link{color:red;} 
a.nav:visited{color:red;} 
a.nav:hover{color:blue;} 
a.nav strong{color:black;} 
a.nav:hover strong{color:red;}
#menu{
	margin-left: 0px;
	width: 150px;
	height: 100%;
}
#main{
	margin-left: 150px;
	width: 100%;
	height: 100%;
	color: white;
}



Home.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
	<title></title>
	<link rel="stylesheet" type="text/css" href="mycss.css">
</head>

<body bgcolor="black">
<div class="menu">
<table width="150px">
<tr>
<td class="menu" style="text-align: center">
<a class = "nav" href="Home.html"><strong><</strong>Home<strong>></strong></a>
<br>
<a class = "nav" href="Tutorials.html"><strong><</strong>Tutorials</strong><strong>></strong></a>
<br>
<a class = "nav" href="Source.html"><strong><</strong>Source Code<strong>></strong></a>
<br>
<a class = "nav" href="Art.html"><strong><</strong>Artwork<strong>></strong></a>
<br>
<a class = "nav" href="Resources.html"><strong><</strong>Resources<strong>></strong></a>
<br>
<a class = "nav" href="Downloads.html"><strong><</strong>Downloads<strong>></strong></a>
<br>
<a class = "nav" href="AboutUs.html"><strong><</strong>About Us<strong>></strong></a>
<br>
</td>
</tr>
</table>
</div>
<div class="main">
<table width="100%">
<tr>
<td style="text-align:center">
NEWS
</td>
</tr>
</table>
</div>

</body>
</html>



I don't know why it's not working. Anyone got any ideas?

Share this post


Link to post
Share on other sites
Advertisement
I think that the <div class=""> should be <div id="">. Also, your DTD is wrong. It should be an absolute URI, not a relative one. This can cause the browser to go in quirks mode instead on stadard complience mode and do unexpected things. Perhaps using a higher DTD (like XHTML 1.0 transitional) makes a difference as well.

Share this post


Link to post
Share on other sites
You are getting your selectors wrong.

A selector of #menu applies to an element whose id is menu.

A selector of .menu applies to an element whose class is menu.

They are completely independent (unless the element whose id is menu happens to have a class of menu)

Mark

Share this post


Link to post
Share on other sites
Additionally you should note that id should use a document wide unique name. If you have mutliple elements you want to format the same use 'class', if you only have a single element you want to style use 'id'.

So in your example you should stay with the definition in your stylesheet and change the div tag to

<div id="menu"> ... </div>


because you're probably going to have only one element you want to style this way.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!