Style always stripped from td element

  • I am trying to find a solution to the style being stripped out of my table cell tags. The unpublished page is here: https://starkaaup.wordpress.com/?p=737&shareadraft=557cad8fa90ba. The tag I’m trying to use is<td style="padding:2px 0 2px 5px;border:1px solid #B0C4DE;font-size:85%;line-height:1.25;"> but it keeps reverting just to <td>inexplicably. Yet I already have a previously-published page here https://starkaaup.wordpress.com/ssc-salary-index-fy/ that includes the exact desired table formatting and it has kept all the styles intact with no problem whatsoever.

    I have searched the forums and Googled my heart out, with no luck – while I have seen many similar problems posted by others, none of the offered solutions have worked for me. I have tried creating a brand new page and using *only* the text entry editor (never switching to the visual tab at all) then immediately saving as a draft or publishing the page (I tried both of these) but I still get the same terrible result because the style tags are stripped in the preview page no matter what.

    I am thoroughly confused, especially since I never had any problem with the previous one. All I am trying to do is create another very similar page that includes updated figures/data in the table cells, but the table formatting is the same as before.

    I have double-checked and see no errant tags or other differences aside from a change in numbers and the text in the actual cells. I might understand this more if the table styling just failed to work on *any* page, but I cannot for the life of me figure out why it would work fine on one page but not another. It has always been the same blog theme, so that hasn’t changed either. Thanks very much for any help you can provide.

    The blog I need help with is: (visible only to logged in users)

  • I tried to reproduce your case, and it works fine at my end.

    In the unpublished draft that you linked to, the table headings row is properly formatted:
    <th style="width:30%;padding:2px 0 2px 5px;font-size:85%;background-color:#dddddd;border:1px solid #B0C4DE;color:#ad0940;">

    The problem you seem to be having are the subsequent rows and its cells. I tried to style them using the code you provided:
    <td style="padding:2px 0 2px 5px;border:1px solid #B0C4DE;font-size:85%;line-height:1.25;">
    and the preview showed expected style.

    Can you try adding a new post and applying the styles again?

  • Hi, thanks! Yeah exactly, the table headers are always fine but it’s the actual cells following in the rest of the table that are being problematic. And I just cannot figure out why. I created a new “Test Page” and pasted in the code on the text tab, took a screenshot (https://starkaaup.files.wordpress.com/2015/06/snip.png) to show what it looks like then immediately hit preview without touching anything else or changing tabs … and no go. Did it again but published the page directly instead (I reverted it to a draft now, but page is here: https://starkaaup.wordpress.com/?p=747&shareadraft=557cd8d51edcd) and still no go. I surely wish I could figure it out – seems like it should be so simple. Thank you for the help.

  • Just out of curiosity, I just tried doing the same using Chrome instead of Firefox and no luck there either. I didn’t really think a different browser would solve the issue, but at this point I’ll try whatever.

  • This is interesting and I’m not sure why the editor is stripping out style attribute in this case. It works fine at my end and on the other pages of your blog too, this exact style!

    Let us know if you find something. I’ll try to dig more as well.

  • This calls for some caps-lock use: I FINALLY FOUND THE PROBLEM!

    It’s the smart quotes vs. straight quotes included in the style attribute that is causing them to strip out. I only actually noticed this because I got frustrated and pasted in a snippet of text from the table that is working to see what would happen – then I finally caught a *very* slight difference in the appearance of the quotation marks from the working table’s <td style> tags and those in the non-working table. Geez. Originally it was just easier to work out the lines of code for the new table in a Word doc so I could use the find/replace function for each <td> tag, and then copy & paste the whole thing into the the text editor on WordPress in one swoop without having to manually type in each line. It doesn’t pick up all that funky Word formatting when you do it that way (like it does when you paste from Word into the visual editor tab) but I guess that doesn’t carry over for smart quotes, too? Weird. Once I did a find/replace in Word to change them all to straight quotes and re-pasted it into the text editor, it works fine on the page.

    Lesson learned. That was completely crazy and certainly an exercise in eyesight, I guess. It might be useful for other users in the future for that piece of info to be somewhere in the help docs – I’m sure I can’t possibly be the only person who might copy over something from Word text into the text editor and assume it is simply pure text.

    Thanks so very much for your willingness to help. :)

  • I’m sure I can’t possibly be the only person who might copy over something from Word text into the text editor and assume it is simply pure text.

    MSWord is terrible as an HTML editor because it brings over a lot of junk code that will eventually foul things up. MS LiveWriter is preferred. https://en.support.wordpress.com/xml-rpc/windows-live-writer/

    But, here’s how to use MSWord cleanly: https://en.support.wordpress.com/microsoft-word/

  • Agreed, it is terrible and I don’t use Word as an html editor (I can imagine few things more annoying, lol!) I don’t do a huge amount of that anyway, and usually the WordPress platform is more than sufficient and friendly.

    In this particular instance I had just wanted to use the replace function for unstyled td tags in the html table I already had. It’s a long table with 400 rows so my (lazy) thinking was to avoid pasting in the style by hand in WordPress for each line and just quickly paste my existing text code into Word, find/replace what I needed, copy/paste back to the plain text editor without fuss. Huge mistake, those smart quotes are apparently persistent little devils. I think perhaps Notepad would have just been a better choice for a quick fix.

  • But thank you! That is good info to have :)

  • You’re welcome.

    When I was still coding by hand, I used a plain text editor called EditPad Classic. Could run circles around Notepad.

  • Such minor things can cause major frustration!

    I personally use Notepad++ (open source), supports syntax highlighting, find/replace and doesn’t mess up text encoding.

  • The topic ‘Style always stripped from td element’ is closed to new replies.