Invalid XHTML for paragraph in table cell
-
Trying to validate my site The Motivational Speaker, I get missing closing tags for paragraphs within table cells. I cannot correct this manually, as the post editor simply strips my explicit tags and “corrects” the code, producing again the invalid XHTML.
See validation results.
-
Admin/Settings/Writing. Try toggling the “WordPress should correct invalidly nested XHTML automatically” checkbox.
@esmi Thanks, but not such luck. On or off, I get the same result with a missing
</p>
before the</td>
Slight tangent but why are you adding
<p>
tags to table cells? Given that table markup is supposed to be reserved for pure data, paragraph tags have no place within a cell. Cell padding should be accomplished by CSS.Just a though but have you tried leaving 1 blank line between your closing
</p>
and your closing</td>
?Actually, WordPress (tinyMCE) is doing this, not me. There are no paragraph tags anywhere, because the post editor takes them out and only puts a blank line between two paragraphs, but when WordPress creates the XHTML from my post, it replaces some things with paragraph tags.
As you can see on the site, I have a heading, followed by some text in a table cell. All I do is press Enter after the heading and then restyle the text as paragraph, which makes the editor remove the heading tags, but WordPress replaces the opening tag later, except it doesn’t do the same with the closing tag.
Me thinks it’s a bug.
Yo, WordPress developers! How about a little response for the nice man?
Did this ever get resolved? I am having a terrible time trying to get paragraphs within my table cells. Nothing seems to work to get the space between paragraphs to remain.
Alas, it wasn’t. Still getting no ending tags for paragraphs ??
Just copied and pasted the HTML from your post (the table code), added the closing P tags back in, and previewed the post, all code is there as expected.
Disable your plugins and see if there’s any change in behaviour when you save the post. Of course remember, you’ll need to edit the post/page again after disabling, and add the missing tag(s) back in. You won’t know if it’s helped until you’ve updated the post/page and attempted to save with the plugins disabled.
In any case, i cannot replicate your issue at this time on WP 2.9.2.
Well, when I do what you’ve done, the tags remain, but when I switch the editor to Visual mode and back to HTML mode, they vanish and the resulting web page goes back to being invalid.
Deactivation of plugins makes no difference. It’s the WordPress editor.
Just in case, I checked “WordPress should correct invalidly nested XHTML automatically” and tested again. No luck.
I believe what happens is that end-of-lines before the closing TD tag is removed by the editor and when the page is prepared for the browser, it is left as is. If I insert two end-of-lines before the closing TD tag in HTML view and save, the page is coded correctly!
Here’s the table code, as it appears in HTML view within the WordPress editor, if anyone wants to test:
<tbody> <tr> <td> <h3><a href="https://www.themotivationalspeaker.biz/index.php/motivational-presentations/cultural-awareness-and-diversity/">Cultural Awareness and Diversity</a></h3> <a href="https://www.themotivationalspeaker.biz/index.php/motivational-presentations/cultural-awareness-and-diversity/"><img title="diversity" src="https://www.themotivationalspeaker.biz/wp-content/uploads/2009/03/diversity2.jpg" alt="diversity" /></a>A range of experiences and interactive presentations about acceptance, culture, immigration, multilingualism, multiculturalism and social justice.</td> <td> <h3><a href="https://www.themotivationalspeaker.biz/index.php/motivational-presentations/communication-and-relationships/">Communication and Relationships</a></h3> <a href="https://www.themotivationalspeaker.biz/index.php/motivational-presentations/communication-and-relationships/"><img title="diversity" src="https://www.themotivationalspeaker.biz/wp-content/uploads/2009/04/family3-300x231.jpg" alt="diversity" /></a>Simple, accessible and practical workshops and presentations about communication, relationships, teamwork, love, friendship, parenting and just how to get along with others.</td> </tr> </tbody> </table>
Tested again, my output.
<table> <tbody> <tr> <td> <h3><a href="https://www.themotivationalspeaker.biz/index.php/motivational-presentations/cultural-awareness-and-diversity/">Cultural Awareness and Diversity</a></h3> <p><a href="https://www.themotivationalspeaker.biz/index.php/motivational-presentations/cultural-awareness-and-diversity/"><img title="diversity" src="https://www.themotivationalspeaker.biz/wp-content/uploads/2009/03/diversity2.jpg" alt="diversity"></a>A range of experiences and interactive presentations about acceptance, culture, immigration, multilingualism, multiculturalism and social justice. </p></td> <td> <h3><a href="https://www.themotivationalspeaker.biz/index.php/motivational-presentations/communication-and-relationships/">Communication and Relationships</a></h3> <p><a href="https://www.themotivationalspeaker.biz/index.php/motivational-presentations/communication-and-relationships/"><img title="diversity" src="https://www.themotivationalspeaker.biz/wp-content/uploads/2009/04/family3-300x231.jpg" alt="diversity"></a>Simple, accessible and practical workshops and presentations about communication, relationships, teamwork, love, friendship, parenting and just how to get along with others. </p></td> </tr> </tbody> </table>
First time round i assumed you were adding the Paragraphs, this time i tested without, my result is still the same, valid code.
NOTE: If you’re entering custom HTML into a post, the editor will naturally wreck that code if you switch to and from visual and HTML modes.
What’s wrong with tables? Since when are they “custom” html?
What could be the difference between your WordPress and mine (2.9.2)?
Should I use wp-table?
I just tested again, switched to visual, saved, tested post, switched to html, saved, tested post, and repeated the above once more.
In each case, the correct HTML is preserved.
Whatever the reason, it’s not happening on my installation.
Test under another theme?
Good idea.
Tested with both “default” and “classic” in preview mode, then switched fully to “classic”, inserted paragraph tags in HTML view, switched to Visual, switched back to HTML (tags gone), then viewed page.
Same result. No ending tags for paragraphs. Looks like it’s not plugins and it’s not the theme.
Oddly enough, a workaround I’ve found was to surround the paragraph with a DIV. The Visual switch makes P tags into double line-breaks before and after my paragraph, so now, the top of the table code looks like this:
<table class="squares" border="0" align="center"> <tbody> <tr> <td> <h3><a href="https://www.themotivationalspeaker.biz/index.php/motivational-presentations/cultural-awareness-and-diversity/">Cultural Awareness and Diversity</a></h3> <div> <a href="https://www.themotivationalspeaker.biz/index.php/motivational-presentations/cultural-awareness-and-diversity/"><img title="diversity" src="https://www.themotivationalspeaker.biz/wp-content/uploads/2009/03/diversity2.jpg" alt="diversity" /></a>A range of experiences and interactive presentations about acceptance, culture, immigration, multilingualism, multiculturalism and social justice. </div></td>
The page renders correctly.
Weird. Very weird…
- The topic ‘Invalid XHTML for paragraph in table cell’ is closed to new replies.