WordPress.org

Ready to get started?Download WordPress

Forums

Unwanted line break inserted after a label tag (6 posts)

  1. matthewpaul
    Member
    Posted 5 years ago #

    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>
  2. Eternal Sky Chaz
    Member
    Posted 5 years ago #

    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!!!

  3. ericmparks
    Member
    Posted 5 years ago #

    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!

  4. gchamaa
    Member
    Posted 5 years ago #

    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?

  5. gchamaa
    Member
    Posted 5 years ago #

    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.

  6. matthewpaul
    Member
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic