Welcome to WebmasterWorld Guest from 54.166.239.238

Forum Moderators: not2easy

Message Too Old, No Replies

UTf8 and validation error

     
8:47 am on May 7, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Oct 25, 2006
posts: 1005
votes: 0


I have code on UTF8 pages like:
[PHP]
<ul>
<li>
<span>

<div style="margin: 10px 5px 0px;"></div><div style="border-style: dotted; border-width: 1px; padding: 2px 0px 2px 5px; background-color: rgb(225, 255, 230); margin-bottom: 3px;"><a href="index1.html">My index file</a></div><div style="margin:10px 5px 0px;"></div>

</span>

</li>
</ul>
[/PHP]

I can not modify this working code. Is there solution to fix this issue?

Error message:

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>").
9:29 am on May 7, 2011 (gmt 0)

Senior Member

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

joined:Sept 25, 2005
posts:1057
votes: 85


I'm confused. What does this particular HTML error have to do with the character-encoding of your page? And your question is, how can you make the page validate when you're unable to change the code?

The validator trips over the
DIV
tags, which are block-level elements, that are placed within
SPAN
tags (an inline element). If you can't alter the code to take out those
SPAN
tags, you can't make this validate.

Also, if you can post the code here, how can it be that you cannot alter it? Or are you saying that you cannot alter the code without breaking the layout?
5:14 pm on May 9, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


You have two problems there, the block level divs are not valid inside the inline elements span *and* li.

The simplest solution (though it's still twisted up) is to change the inner divs to span and assign a display:block to them to emulate block displays. At least it will validate, but other problems may arise (block level elements inside inline elements = bound to be difficult.)

The cleanest solution would be to break all that down into li -> span -> a . . . but you claim you can't mod it so don't know what you'll do.

(Let me guess, Wordpress?)