Forum Moderators: not2easy

Message Too Old, No Replies

how to make a div validate

<div id = "wrap1" "wrap2">

         

shumboom

4:31 pm on Nov 28, 2008 (gmt 0)

10+ Year Member



Hi

I recently inherited this code

<div id = "wrap1" "wrap2">

which will not validate in xhtml. It gives the following error message

"An attribute name (and some attribute values) must start with one of a restricted set of characters. This error usually indicates that you have failed to add a closing quotation mark on a previous attribute value (so the attribute value looks like the start of a new attribute) or have used an attribute that is not defined (usually a typo in a common attribute name). "

The css code for wrap2 is only to set the width to 500px;

My questions are
1. What is the effect of putting two attributes to the ID on the div. I cant find any instructions on this type of code?
2. How do I get it thru the validation? Ive tried two divs, and also removing the wrap2 attributes and adding them to wrap1 but neither worked.

thanks

HelenDev

4:53 pm on Nov 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think if you were using classes rather than divs you can do

<div class= "wrap1 wrap2">

Not sure if you can do this with ids though. If this doesn't work can you change your ids to classes instead?

g1smd

9:02 pm on Nov 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The correct notation is <div class="wrap1 wrap2">

The attribute value is a list of single-word class names.

I haven't looked to see if the same thing can be done with ID.

shumboom

10:24 am on Nov 29, 2008 (gmt 0)

10+ Year Member



Thanks!

g1smd

10:51 am on Nov 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use the Firebug extension for Firefox to examine the document after you apply this, as sometimes you have to repeat some of the properties (like margins) into both classes otherwise you don't get the display value you expected.