Tuesday, July 05, 2005

Is this OK, or am I a XHTML-Terrorist

Working on converting a large content managment driven site to Valid XHTML and is trying to keep all Editorial functions as they are.

I'm parsing text from a textarea. I start by defining a paragraph and parse two or more newlines to end it and create a new paragraph. The Editors are allowed to put a picture with caption, a quote block, a fact box etc. wherever they want in the body text (and have been doing so in tens of thousands of articles that I have to keep).

Nesting a <div> inside a <p> ... </p> is not valid and I cant't force the image, qoute, factbox... to be placed outside the paragraph. The only easy solution I want to use is to put the elemts inside a inline-element such as a span, making it valid, but redefine the span to display: block;

<style type="text/css">
.float {
display: block;
float: right;

Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Etiam vitae sapien. Quisque dictum. Nunc orci
<span class="float"><img src="lorem.jpg" width="100" height="150" border="0" alt="alttext" />
<br />Caption
lacus, rutrum eu, elementum quis, rhoncus iaculis, risus.
Pellentesque habitant morbi tristique senectus et netus
et malesuada fames ac turpis egestas.

Is fooling the validator like this OK? Or am I terrorising the quest for a valid marked-up internet! I think it's for a good cause. The Image in this example is inline, inside a pargraph where it actually belongs if that's where the Editor put it. The blockifying done with CSS is just for layout purposes!

Powered by Blogger Weblog Trackback by HaloScan.com