View Full Version : My <div> tags aren’t working?

11-11-2012, 07:16 PM
Hello there,I'm very new to this but i'm trying my best to learn.
Can SOMEONE EXPLAIN ME DIVS,POSITIONING stuff like that? WHEN I SEE PEOPLE TRANSFORM PSD > HTML looks so easy for them but for me its heck of a job!

This is my code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="style.css" rel="stylesheet" type="text/css" />


<div id="banner"> <!-- the logo goes here-->
</div> <!-- end of the banner-->

<div id="navigation"> <!-- the navigation -->
<ul id=navigation">
<li><a href=#>About Us</a></li>
<li><a href=#>Gallery</a></li>
<li><a href=#>Contact Us</a></li>
<li><a href=#>Events</a></li>
<li><a href=#>News</a></li>

<div id="News1"> <!-- the latest news content goes here-->

<div id="News2"> <!-- the not so latest news content goes here-->

<div id="Footer"> <!-- the bottom -->

<div id="Background"> <!--the background -->

but when i open my style.css and for example I write

#News2 {

nothing happens, i do have a folder named images and i do have that image.
I don't know what is my css supposted to consist for my div tags to work?

I tried Body
background-size:1380px 1024px;

and the background did changed

11-11-2012, 09:58 PM
when for this in html

<div id="navigation"> <!-- the navigation -->
<ul id=navigation">
<li><a href=ԣԾAbout Us</a></li>
<li><a href=ԣԾGallery</a></li>
<li><a href=ԣԾContact Us</a></li>
<li><a href=ԣԾEvents</a></li>
<li><a href=ԣԾNews</a></li>

i write in css this


width:730px; margin-left: auto; margin-right: auto;


my navigation shows,can someone explain me more about div's and how to properly use them,I'm a newbie trying to learn something.
also can someone tell me how you guys can be so precise into positioning things?

11-11-2012, 10:11 PM
Hello kikaz,
The example you've quoted here is invalid. You can only use the id navigation once, see an explanation here (http://www.tizag.com/cssT/cssid.php).

Divs are just boxes of content. It's a very common mistake for new coders to use too many of them, see divitis here (http://www.apaddedcell.com/div-itis).

In the case of the example you've posted, does your ul really need wrapped in another box? That ul can stand on it's own just fine, or it may be that another div is needed to hold a background image that your ul menu sits in.

11-11-2012, 10:39 PM
It may be quite insignificant but you also left off one set of double quotations after the id= in your <ul> element.

Kind regards,