PDA

View Full Version : Valid XHTML 1.0 error question


Boofo
03-25-2008, 07:14 AM
Can anyone tell me why this line is not passing XML validation and how to fix it? I can get rid of the error if I use span instead of div but I need the padding for these links.

<strong><div style="padding:4px;0px;4px;0px;"><a class="sitemap" href="' . $vbulletin->options['bburl'] . '/forumdisplay.php?f=' . $forumid . '" style="font-weight:bold;font-size:12px;" title=" ' . $forum[title] . ' ">';

I'm using it in a php file and it works but I get this message on validation:

document type does not allow element "div" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag .

The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.
One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

SEOvB
03-25-2008, 07:17 AM
try to move the div tag outside of the <strong> tag and be sure to close the strong and div tags

and your padding: markup is wrong i think, shouldn't it be

padding: 4px 0px 4px 0px;


?

Boofo
03-25-2008, 07:37 AM
Both ways seem to work on the padding and it gives no error. But I changed it to your way if that is the right way.

Thank you, sir, that fixed it. I didn't know validation could be so touchy on such minor things. Now I've got the home page and the site map all validated for XHTML 1.0 and CSS.

I've been having a blast fixing the errors as I find them (I really need to get out more I think). The default vb skin even had a few minor ones.

SEOvB
03-25-2008, 07:54 AM
Good to know the padding used that way works though :) first time i've seen it coded that way

Boofo
03-25-2008, 08:58 AM
I'm a coding pioneer. ;)

Thanks again for the help. I'm on a quest to get the whole site validated. I may pop back in here if I run into any problems. I reported one from the search_forums to the com. It seems they use autocomplete= in there and the validation doesn't like that.

Princeton
03-25-2008, 01:31 PM
your problem was that you were trying to embed a block-level element within an inline element

I suggest the following:
<div style="padding:4px;0px">
<a href="">
<strong>title</strong>
</a>
</div>

or


<h2>
<a href="">title</a>
</h2>


block-level / inline elements (http://htmlhelp.com/reference/html40/block.html)

Boofo
03-25-2008, 01:41 PM
The first code is basically what I went with. So my padding code was right then?

What does the <h2> do?

Jase2
03-25-2008, 02:25 PM
It is used for an header on your webpage.

http://www.w3schools.com/tags/tag_hn.asp

Regards Jason :)

Boofo
03-25-2008, 02:41 PM
I tried the <h2> tags and they did great for the bold part but did way too much vertical spacing. I'll keep those in mind though, thanks! ;)

Brueskie
03-25-2008, 04:02 PM
You can style your h1, h2, etc. tags via CSS to make them smaller, larger or whatever. For instance, you can add the following to the Additional CSS Definitions in your Style Manager:

h2 { font-size: 10pt; }

Boofo
03-25-2008, 04:05 PM
I liked the font size but there was just too much vertical space using those tags. I use the h2 tags for my welcome message as I have a header text in that that is 150% size.