Need help? Check out our Support site, then

posts rewriting html code

  1. 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>

    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?

  2. 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 ;)


  3. Which editor are you using? I'm wondering what's doing the actual switch: TinyMCE or the security backend of the code.

  4. 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

  5. Do you see icons along the top or the html tags?

  6. @drmike: it isn't the editor. Both the visual and code editor get converted.

    When you save a post on 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
  7. html tags -- he was writing in the Code window.

  8. >>you posts you put the contents *outside* of the span

    That was an example of the results he got.

  9. Is there any possibility of getting this problem addressed? It's rather frustrating not to be able to use span and div tags.

  10. have you sent in feedback to staff as suggested by Trent? You'll have to wait until Monday, though

  11. 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:

    <p>1st paragraph.</p>
    <p>2nd paragraph.</p>

    Haven't heard anything further for several days.

  12. @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).

    I'd recommend using:

    <ul id="blah">
    <li>1st paragraph.</li>
    <li>2nd paragraph.</li>

    and then styling it how you want.

  13. 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.

  14. I've run into this with div tags, too. I was trying to put pullquotes into a 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.

  15. Is there any chance of getting this fixed in the foreseeable future?

  16. I would suggest feedback with an explaination of what is occuring along with a link back to this thread.

  17. Did it twice already. Nothing.

  18. 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:

    According to the FAQ, DIVs are "allowed". See here: But they aren't really "allowed" if the editor is converting them to P tags.

  19. 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).

  20. you could have multiple spans, inside other spans.

    <span class="my_Box">

    or, this might be an instance where a table makes sense.

    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.

  21. *snort* Best feature of wordpress? You have used it, right? ;)

    From my read of Andy's response, it's more of a HTML 4.01 issue than a TinyMCE issue.

  22. SPANs are really irrelevant to what I was trying to do. I only tried SPANs as a workaround. The editor rewrites SPANs to make them HTML 4.0 compliant. I'm fine with that. But what doesn't make any sense to me is converting DIVs to Ps. The are not the same, do not serve the same purpose. Andy's email said this is the designed behavior and they do not intend to change it. So the only way around this bizarre feature is to turn off the rich text editor. As I pointed out in my response to Andy's e-mail: this editor behavior makes life harder for everyone who wants to use a DIV on the rationale that somebody might use it when what they really mean is a P. I think that is, to say the least, a debatable design decision. How often is it going to happen that somebody goes to all the trouble in the rich editor to switch to code view to type a DIV tag when what they really want is something ELSE? I can't get my mind around the logic of this reasoning.

  23. @drmike- i use it every time i post. the people who complain about it being crap don't use it. i'm no stranger to writing code. when i post about my weekend, i don't want to write about it in code.

    there's a hack for standalone wordpress that will return the div functionality to the rich text editor. it's not an issue with HTML 4.0* , it's an issue with automattic thinking that you won't need to use div's inside a post. they specifically changed the rule, it's a bad change, and it should be reverted.

    * the block element inside an inline one is fine, and valid, and only affects the workaround, not the issue of div's

  24. I guess there's no any specific design decision; it's just happened that there's a raison d'ĂȘtre: people who use HTML don't use RTE.

    so called rich text editor (TinyMCE) is a third-party project which is included into WP core for some time (it has its own user forums).

    there are many popular FOSS projects around that actually grown up rather than designed -- not sure if any particular logic could be found behind some misterious behavior of theirs (apart from "it just works!").

  25. We will re-evaluate the reasons for converting DIV to P.

    It had something to do with the way some browsers implement design mode, the feature that makes WYSIWYG work, and the alignment buttons.

    Please understand that we have many other things on our plates and this one just isn't a high priority. TinyMCE is open-source, so if you're inclined to help please contribute code to MoxieCode or

  26. Here is the reasoning behind converting DIVs to Ps that was given to me in email from WP support:

    The DIV/P conversion is intentional. It is done when the content is taken from the rich editor (i.e. when saving or switching editors). We do this because, due to browser quirks, the rich editor sometimes creates DIV tags when P tags are wanted. Compared to your scenario, the frequency of this scenario is overwhelmingly more compelling. It's a case of the unskilled majority being favored over the expert minority.

  27. I wonder if I could write a Firefox extension to change this?

    I was playing around with the idea of writing a tinymce expert extension that did things like:

    - remove the spellcheck function and turn on firefox spellcheck
    - automatically enable the Alt-Shift-V hidden menu

    I'm not sure if this conversion is happening on the java TinyMCE side or the backend, but it sounds like it's happening on the Java side which means it can be tweaked.

    I wish I had more time.

  28. the file that gets hacked is formatting.php, so i'm pretty sure it's on the backend.

    and at least for me, the firefox spellcheck now checks the RTE field.

    given the answer that garyglass got, i dunno that i'm qualified to submit patches on the subject.

  29. admittedly, I didn't have enough time to investigate (and test) whether this issue is caused by an erroneus richedit behavior, judging by the [#3826] bug ticket [of normal prority, milestoned to the 2.1.3, has no patch; not tested] it seems like this problem is on the backend side.

    also, function wpautop() is definitely needs to be revised thoroughly as I was able to reproduce a bug in the ticket [#3007] opened 8 months ago (see also tickets ##: 3935, 3669, 2348, 1099).


    I wonder if I could write a Firefox extension to change this?

    I think it could be done by means of a GreaseMonkey user script; needs time too but somewhat less than full fledged extension though.

Topic Closed

This topic has been closed to new replies.

About this Topic