posts rewriting html code
-
Here’s what I want to do: Make a float-right box. Here’s how I’d normally do it:
<div class=”my_box”>
<p>first graf</p>
<p>second graf</p>
</div>And make a CSS my_box class to do the work.
But if I put this code into my entry, the editor very unhelpfully converts it to this:
<p class=”my_box”></p>
<p>first graf</p>
<p>second graf</p>Why are the div’s converted to p’s?
So I tried the same thing using span instead of div. And I get this output:
<span class=”my_box”></span>
<p>first graf</p>
<p>second graf</p>I get to keep the span, but the contents are moved out of it.
What’s up with this?
-
If you don’t get a response from someone who has a better explanation here soon, I would suggest sending in a feedback through the admin or an email tomorrow morning to support at this domain for a better explanation of why this is happening and what you can do. I just didn’t want your post getting buried without any response if no one here has some ideas for you ;)
Trent
-
Which editor are you using? I’m wondering what’s doing the actual switch: TinyMCE or the security backend of the code.
-
Drmike, We don’t know what the editor is called — he’s just using the interface for “Write Post.” (Gary is helping me with my blog http://cvillewords.wordpress.com.)
-
-
@drmike: it isn’t the editor. Both the visual and code editor get converted.
When you save a post on wordpress.com all DIV tags are converted to paragraphs. Any HTML elements with “class” (other than span) have the class removed (“id” works ok though).
@garyglass: switching the DIVs to SPANs is the way to go, but if you look at the example you posts you put the contents *outside* of the span.
<span class="my_box"> first graf second graf </span> -
-
>>you posts you put the contents *outside* of the span
That was an example of the results he got.
-
Is there any possibility of getting this problem addressed? It’s rather frustrating not to be able to use span and div tags.
-
have you sent in feedback to staff as suggested by Trent? You’ll have to wait until Monday, though
-
Yes, I did. We discussed CSS issues, but I pointed out that CSS really has nothing to do with it. The problem is that the editor is reformatting the HTML. Try it:
<span>
<p>1st paragraph.</p>
<p>2nd paragraph.</p>
</span>Haven’t heard anything further for several days.
-
@garyglass: You’re right. It’s an HTML thing. Spans have to be embedded within a paragraph, not outside of it. So the editor is forcing valid HTML (there’s an option for it on your profile page, I think).
http://www.w3schools.com/tags/tag_span.asp
http://fulltimer.org/lesson8.htmlI’d recommend using:
<ul id="blah"> <li>1st paragraph.</li> <li>2nd paragraph.</li> </ul>and then styling it how you want.
-
Yeah, well, as I noted in the original post DIVs act the same way. The only reason I tried a SPAN was that a DIV didn’t work. I don’t want to use a list tag to make a box, I want to use a DIV. That’s what they’re for.
I don’t find the option for turning off validation. If anybody knows where it is, please post.
-
I’ve run into this with div tags, too. I was trying to put pullquotes into a wordpress.com blog a couple months ago using some code from Mandarin Design blog. But the divs kept getting converted to ps. I tried span classes, couldn’t get it to look right, and gave up – I’m a rank amateur at this, and was in well over my head. Glad to hear it wasn’t just me.
-
-
I would suggest feedback with an explaination of what is occuring along with a link back to this thread.
-
-
Sent it a 3rd time. It’s hard to tell whether it works or not as it doesn’t give me any “feedback” like “Sent! Expect a response from the support within minutes!” Here’s what I sent:
This is my third time asking this question. Can we please get a fix for the editor converting DIV tags to P tags? I want to be able to making a float right box. DIVs are the way to do that, but I can’t do it if DIVs are converted to Ps. See discussion here: https://en.forums.wordpress.com/topic.php?id=8519&page&replies=17
According to the FAQ, DIVs are “allowed”. See here: http://faq.wordpress.com/2006/06/08/allowed-html-tags/ But they aren’t really “allowed” if the editor is converting them to P tags.
-
Replied in email. To paraphrase:
DIV is converted to P by the rich editor. Turn off the rich editor in your profile.
P (a block element) does not belong inside SPAN (an inline element).
-
you could have multiple spans, inside other spans.
<span class=”my_Box”>
<span>graph1</span>
<span>graph2</span>
</span>or, this might be an instance where a table makes sense.
@andy-
turning off the rich text editor is a really bad suggestion. this is a bug that should be fixed, not worked around by disabling one of the best features of wordpress.
- The topic ‘posts rewriting html code’ is closed to new replies.