WordPress editor keeps rewriting my HTML code
-
… and it keeps screwing up the way things display on my page.
For instance, if I click “preview” when I’ve left off a </div> it moves everything around and even reformatted a command to embed a Youtube video so the command would no longer parse correctly. I would MUCH rather get an error message than have the editor silently change my code!
It also does this with inserted spaces and hard line breaks ( and
commands)
In fact if I have inserted a blank (&nbps) in the HTML view and then go back to the “Visual” view, the editor deletes my blanks!Right now I can’t get the spacing I want and I have no idea why. Possibly there’s some minor error in the HTML but it’s not telling me where it is and in the meantime it is sometimes (but not always) ignoring these commands. Using <p> to try to force the issue is also of limited value.
I presume there is some artifact left in my code from this annoying and dangerous habit the editor has of rewriting my code that I didn’t manage to extract. In any case I’m tired of having to rewrite entire pages because the editor won’t leave my code alone, for good or ill. I’d rather correct errors I myself have made than have to correct errors the editor has made when compounding some minor error of mine.
How can I turn this behavior off?
Page that continues to misbehave no matter what I do:
At the end there should be a line break before and after the last word (Enjoy!)
In the body there should be a line break before and after “Directions” – currently it is only showing the line break AFTER.
The blog I need help with is: (visible only to logged in users)
-
Before the editor started to look at code to try and prevent errors, these forums were full of postings something to the effect, “OMG!!! I did nothing and my entire post and blog have blown up!!! HALP!!!! People are dying!!!!” We volunteers spent thousands of hours tracking down the problems and helping people fix them. This was not a SMALL issue, it was huge. I personally saw sites with 700 to 800 validation errors, all caused by bad HTML. Today, Google and the other search engines routinely quit indexing sites with too many validation errors. This is part of the way that wordpress is trying to help keep that from happening (saving people from themselves, as it were).
The one thing to remember is that wordpress will hide a good bit of the HTML code in the HTML view to prevent confusion. Most people are not used to looking at all that code and it seriously messes them up.
I would suggest getting one of the blog clients like Windows Live Writer and then use that to create your posts and pages. They will whine and scream if you make mistakes, and they will NOT allow you to publish a messed up post or page. You will either have to have the program automatically fix the issue, or you will have to fix it yourself.
-
One thing to can do is go to settings > writing and make sure it is not set to have wordpress automatically correct invalid nested XHTML. That won’t take away all of the automatic corrections, but it will lessen things I think.
-
You’re simply not quite familiar with HTML and CSS yes.
Remarks on the code of your post, from top to bottom:
a) You wanted some space between the colored div and the content: to do that, you don’t add a second div with margin, you add padding to the colored div.
b) The br tag is used for a line break (= a single return), not a blank line.
c) To create border and padding around some content, you don’t add two separate divs, you add both properties to the same div.
d) There’s no space before “Directions” and “Enjoy” because paragraphs have some default bottom margin but divs don’t: you need to add a bottom margin to the divs that precede those words.
e) A paragraph is a single block of text: you don’t put div tags inside p tags.In all, your code should be like this:
<div style="background-color:#ffd5ab;padding:10px;"> <p>PARAGRAPH TEXT HERE</p> <strong>INGREDIENTS:</strong> <div style="border:ridge #179cc8;margin-bottom:24px;padding:25px 10px 0 0;"> UNORDERED LISTS HERE</div> <strong>DIRECTIONS:</strong> <div style="border:ridge #179cc8;margin-bottom:24px;padding:25px 10px 0 0;"> OORDERED LIST HERE </div> Enjoy! </div> -
justpi, actually I’m VERY familiar with HTML, probably since before you were born (well, maybe since you were a little kid, LOL!), and I have a passing familiarity with CSS as well. The problem was that WordPress, for some insane reason, was not allowing me to combine those options in the single div statement – that is how I originally wrote it. I forget exactly what it was doing – it’s been several months now – but it was reformatting my commands and screwing them up. It started when I left out a single </div> statement and I couldn’t get it to work properly after that even after I tried to put it back to “normal” (ie extract all the WordPress-generated code).
Keep in mind this was happening if I switched from HTML to Visual mode, not just when I tried to publish – I’d set my code up in HTML view, switch to Visual to use some tool there, then when I came back, code had been rewritten. And some of what it rewrote was incorrect syntax that doesn’t parse.
Hence I was trying to brute force what should have been correct code. I couldn’t see ALL the HTML, I don’t have access to the style sheets (which is where I would do this normally), and when that wasn’t working, I fell back on REAL brute force methods of trying to force linefeeds via HTML commands. I have no idea what the problem was, but I’ve turned the autocorrect feature off and I can now go back to a single div statement in all those places. Whatever it was doing, it’s not doing it anymore. So I’m just as happy about that. I’m not about to turn autocorrect back on to see if it goes back to screwing up, LOL!
BTW I’ve bookmarked your posting about how to disable infinite scrolling. If that’s been implemented on my pages I’ll be turning it off soonest. Thanks for the writeup.
thesacredpath, I’m FINE with wordpress refusing to publish a page (or post, to me they’re all pages and “page” and “post” are simply descriptions of particular types of, well, PAGES on a website, but whatever) when it has errors in it. What I’m NOT fine with is it going behind my back and fiddling things, and then I end up with code that IT “wrote” that doesn’t work either!!! I have turned that off and it seems to have solved all the problems I was having.
Well, except for the fact that wordpress chooses NOT to show me all the HTML code when I tell it I want to edit HTML. I routinely code all my pages (you’ll just have to get used to me using “page” for all pages, posts, static pages, etc – they’re all just different types of pages; they’re only different insofar as which CSS rules apply to them) in native HTML (and now CSS). Not seeing ALL the HTML is what throws me off! Not having access to the style sheets is no fun either. If I had the money they want for turning CSS customization on, I’d just get my own hosting and have total control.
At any rate, thanks for telling me how to turn that off. It appears to have fixed whatever was going on. At least I can code normally now, without all the nested divs and
and whatnot, LOL!Of course I haven’t looked at that embedded video yet. I think I’ll quit while I’m ahead ….
Thanks.
-
Some remarks:
• The only thing that’s hidden in the HTML editor is plain p tags and plain br tags.
• The editor doesn’t screw your commands except if you use forbidden code or if you’ve made a typo such as omitting a semicolon or a quotation mark etc.
• But it can mess tags if you’ve left them unclosed: if you have enabled the auto-correct option, it tends to supply missing tags paragraph by paragraph, inserting extra opening and closing tabs at all the wrong places.
- The topic ‘WordPress editor keeps rewriting my HTML code’ is closed to new replies.