• I have a form that uses a list to display its input fields in each list item. WordPress is adding a <br /> tag after each closing label tag in my form.

    How do I prevent WordPress from adding the <br /> tag after each closing label tag? Help is appreciated.

    Below is what the code should look like:

    <li><label for="name">Name</label><input name="name" id="name" type="text" /></li>
    <li><label for="email">Email</label><input name="email" id="email" type="text" /></li>

Viewing 5 replies - 1 through 5 (of 5 total)
  • Chaz

    (@eternalskychaz)

    That’s because they stripped the <br /> and <br /> tags out of v2.6. So now they have the tinyMCE rich text editor putting the line breaks in too often.

    Hey, WordPress! Didja ever think of letting the browsers parse the html code that your users put in their posts??? It would make it easier on all of us (including you!) if you if you did not constantly over think what you were doing!!!

    Does anyone know of a solution to this problem? I’m having the same issue and it’s driving me up a wall.

    This is the way the code should look, and this is what I’m pasting into the edit page field (I’ve disabled the WYSIWYG editor):

    <a href="image.jpg" title="Enlarge Image" class="highslide" onclick="return hs.expand(this)">
    <img src="image2.jpg" title="Click to enlarge" border="0" />
    </a>

    And this is what I see when I view source when I test the page:

    <a href="image.jpg" title="Enlarge Image" class="highslide" onclick="return hs.expand(this)"><br />
    <img src="image2.jpg" title="Click to enlarge" border="0" /><br />
    </a>

    Why is wordpress adding those two line breaks? This is total BS. Why is wordpress messing with my HTML…especially after disabling the visual editor!

    So I am also having the same problem. A break tag is being placed after my label tag. My guess is that it is the TinyMCE editor. I tried to remove all spaces in my editor visually and nothing happened.

    Any solutions to this?

    ha ha, so I found a hacky solution. I generally don’t hack,but I have to get this done. I just put a style to the
    tag of display:none.

    So here is an example:

    <form id="myForm">
    <label>Name</label>
    <br /> [this is the break tag inserted by wordpress]
    <input type="text"></input>
    </form>

    Just add:
    #myForm br {display:none;}
    to your stylesheet.

    Since you should be coding semantically anyway, you should not be using break tags so this shouldn’t effect your other layouts. But let’s say that you do have other
    tags somewhere that you want to display, then just add a general style for
    tags to display normally like such:
    br {display:inline}

    If anyone finds a non-hacky solution, please let me know.

    Thread Starter matthewpaul

    (@matthewpaul)

    Another solution is to code the page as a template, so that the form exists outside of the_content and therefore cannot be edited or altered by the WordPress editor.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Unwanted line break inserted after a label tag’ is closed to new replies.