WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 9 months ago

#32548 new defect (bug)

Unecessary White Space Above Table

Reported by: ChuckC3 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Formatting Keywords: needs-patch
Focuses: Cc:

Description

This may be a known problem but this is the first time I've discovered it. I have found that if I put a table on a page in this format:

<TABLE> <TR> <TD>xx</TD><TD>yy</TD></TR> <TR><TD>11</TD><TD>22</TD></TR> <TABLE>

WordPress will generate a number of unnecessary lines of white space prior to the table. If I remove the white space between the HTML elements so that it looks like this the problem of the unnecessary white space prior to the table goes away but the code looks like crp, of course:

<TABLE><TR><TD>xx</TD><TD>yy</TD></TR><TR><TD>11</TD><TD>22</TD></TR><TABLE>

Here's a link that led me to the solution to this problem::

https://en.forums.wordpress.com/topic/extra-spaces-on-top-of-tables

The above post was from 2007 yet this problem still exists. Is everyone aware of this problem? Is there a solution?

Thanks,

Change History (4)

#1 @iseulde
4 years ago

  • Component changed from General to Editor
  • Keywords reporter-feedback added
  • Version 4.2.2 deleted

Thanks for the report. I cannot reproduce the issue by pasting any of the two examples above. Could you please give us the exact steps to reproduce?

#2 @ChuckC3
4 years ago

Here are the exact steps I used to reproduce this problem:

  1. Create a new page
  2. In the new page, paste the following HTML:

<TABLE>

<TR> <TD>xx</TD><TD>yy</TD></TR> <TR><TD>11</TD><TD>22</TD></TR> <TABLE>

  1. Preview the page
  2. Note the unnecessary white space above the table

I've attached two screen shots to show what this looks like on my system. If you are still unable to duplicate this problem, perhaps it is related to the theme I'm using which is 2012.

Thanks,

Chuck

I couldn't figure out how to attach an image to this so I posted the images here:

https://dl.dropboxusercontent.com/u/15506155/Screen%20Shot%201.jpg

https://dl.dropboxusercontent.com/u/15506155/Screen%20Shot%202.jpg

#3 @swissspidy
2 years ago

  • Component changed from Editor to Formatting
  • Keywords needs-patch added; reporter-feedback removed
<TABLE>
<TR>
<TD>xx</TD><TD>yy</TD></TR>
<TR><TD>11</TD><TD>22</TD></TR>
<TABLE>

Is not valid HTML, but it will end up like this in the DOM:

<table>
  <tbody>
    <tr>
      <td>xx</td><td>yy</td>
    </tr>
    <tr>
      <td>11</td><td>22</td>
    </tr>
  </tbody>
</table>

However, WordPress adds the following before that:

<p></p><br><br><br><br>
…

If you enter the valid table from the DOM in the editor and save the post, not <br>'s are being printed anymore.

Sounds like a wpautop() to me.

#4 @Matthias Reuter
9 months ago

Seems to be a classical wpautop case. When inserting structured HTML into a post, linebreaks will be converted to <br> or <p> through wpautop.

There are plugins available to disable wpautop on certain posts: https://de.wordpress.org/plugins/toggle-wpautop/

This will require users to decide whether to:

  • disable wpautop when linebreak-formatted HTML is used. If you have a big site, you may insert many <p>-Tags and/or <br /> tags manually for formatting text.
  • keep wpautop enabled, but write all HTML in line.

This occurs too with linebreak-formatted div-tags etc.

I don't think this is a bug, as wpautop just does it's job and you should disable it when you work with complex HTML in your Post.

Note: See TracTickets for help on using tickets.