3 replies [Last post]
JC4Life
Offline
Regular
Last seen: 16 years 4 weeks ago
Timezone: GMT-5
Joined: 2003-09-22
Posts: 17
Points: 0

Hello! Because I am having trouble converting my old table-based layout to CSS, I have decided to start afresh. This new design looks pretty cool, but it has a slight problem: when I put it through W3's Validator it complains that the page isnt XHTML valid because it contains nested DIVs. Are nested DIVs not valid? Also, the validator has a problem with me reusing IDs. Sad

Many thanks in advance!

God bless!

Best Regards,
Joe of Christ For Life Ministries

Jesus Christ 4 life! D

Pob
Offline
Enthusiast
Hampshire UK
Last seen: 8 years 19 weeks ago
Hampshire UK
Timezone: GMT+1
Joined: 2003-08-16
Posts: 60
Points: 5

Nested DIVs not valid?

Hi,

Theres nothing wrong with nested divs. You must have something else that's incorrect. Are they correctly nested with opening and closing tags in the correct place etc? Have you nested block level elements inside inline elements by mistake. There could be a number of reasons.

Have you got a link to the page or some relevant code.

You are not allowed to use more than one id with the same name on a page and your page will not validate.

An ID is a unique identifier and refers only to that one element. Unfortunately nearly all browsers will let you assign multiple id's (with the same name) without raising an error. If you need to use an id more than once then it should be a class. (For example if you use an ID to identify an element and that element is being referenced by javascript then the script will fail if it uses getElementById as it will take the first one it sees.)

Paul

freak
Offline
newbie
Last seen: 16 years 2 weeks ago
Timezone: GMT-8
Joined: 2003-10-04
Posts: 7
Points: 0

Nested DIVs not valid?

You probably have them nested incorrectly. Nesting things isn't wrong/bad, it's just that you have to nest them properly.

Example.

<strong><em>text</strong></em>

Is invalid. Because the strong tag opened first it should close last, not first.

<strong><em>text</em></strong>

// freak

JC4Life
Offline
Regular
Last seen: 16 years 4 weeks ago
Timezone: GMT-5
Joined: 2003-09-22
Posts: 17
Points: 0

Nested DIVs not valid?

I thought that I had already replied to this topic, but it must have dissapeared! Anyhow, the problem went away on its own and I fixed the main problem of have same IDs. Thanks, anyhow!

Best Regards,
Joe of Christ For Life Ministries

Jesus Christ 4 life! D