WordPress.org

Ready to get started?Download WordPress

Forums

WP 2.0 xhtml problem (or is it just me?) (9 posts)

  1. SoundTrip
    Member
    Posted 8 years ago #

    When I was on 1.5 I had the blog xhtml strict (until I added an ID tag that was repeated for a specific reason). In short the ID tags caused a couple of validation errors but it was strict once I removed them.

    The upgrade to 2.0 doesn't appear to properly close if a person adds his or her own breaks.

    For example:

    My post conatins the following source in the html based editor:
    <img src ="./images/bp.png" alt="Brad Peterson" class="albumImage"/>
    <h3>Brad Peterson - The Pharmacist</h3>

    WordPress converts this to
    <img src ="./images/bp.png" alt="Brad Peterson" class="albumImage"/>
    <h3>Brad Peterson - The Pharmacist</h3>

    Which of course isn't xhtml compliant because the paragraph should be closed before the

    I never personally add the tags so i didn't expect to see this.

    I will rearrange my code to work around this but wanted to know if there was anything I can do to prevent this going forward.

    Thanks in advance,
    Trip http://www.soundtrip.com/

  2. petit
    Member
    Posted 8 years ago #

    Which of course isn't xhtml compliant because the paragraph should be closed before the

    Excuse me - something must have happened to the "paragraph".
    I can't see any p:s, nor can I see any incompliancy matter.

  3. tsguitar
    Member
    Posted 8 years ago #

    Looking at the code for your home page, there are several reasons the code is no compliant, not the least of which may be some things that WP is doing.

    The first thing I see is that you have a header tag (an H3 tag) inside of a paragraph. That's not right. They are called header tags because they appear at the top (head) of something. You've used them correctly in the sidebar and elsewhere on the page, but in your "Brad Peterson Killed The RIAA Gods" entry, it's all wrong.

    Instead of using all those H3 tags as captions for your photos, why not just use a regular P tag, but give it a specific CLASS which you can then format with your CSS?

    The second thing I see is that you aren't closing your paragraph tags. You have lots of things like this:

    <p><img src ="./images/banooba.jpg" alt="Banooba" class="albumImage"/>
    <h3>Banooba – Sinora </h3>
    <p>Banooba is classified as Groove Rock...

    In that example, you never closed that initial P tag. A BR tag doesn't close a P tag, nor does a header tag (that H3). You should be writing things more like:

    <p class="image"><img src ="./images/banooba.jpg" alt="Banooba" class="albumImage"/></p>

    <p class="caption">Banooba – Sinora</p>

    <p>Banooba is classified as Groove Rock...

    That would validate. You'll need to re-examine how you are telling WP to build your pages and consider restructuring the code to be valid, particularly if you're worried about using a strict DOCTYPE.

    Oh--there is no valid reason to repeat an ID on a page. If it repeats, code it so that it's a CLASS, not an ID. ID is for unique items; CLASS is for multiple items.

  4. vkaryl
    Member
    Posted 8 years ago #

    First thing you need to do: validate your page.... http://validator.w3.org/

  5. SoundTrip
    Member
    Posted 8 years ago #

    The first thing I see is that you have a header tag (an H3 tag) inside of a paragraph. That's not right. They are called header tags because they appear at the top (head) of something.

    But that's the point. I didn't put the Paragraph tags anywhere on my site. WordPress or the editor generated them. I certainly would have closed the paragraph tags BEFORE putting the header tags in had I done them myself (hence the xhtml specification).

    First thing you need to do: validate your page.... http://validator.w3.org/

    Agreed, and like I said, the page was xhtml strict compliant using the validator until I upgraded to WP2.0. i added some ID's to make a shortcut that threw some errors recently but that was it.

    It seems that people here are very defensive about even the suggestion that WP2.0 might have caused the problem. That is a bit counterproductive.

    It could be that my template was treated in a much more forgiving manner in 1.5. I did not have this problem until I upgraded to 2.0 and I checked the referrer often.

  6. SoundTrip
    Member
    Posted 8 years ago #

    Here's the fix:

    The Editor will not handle header tags if they are not on seperate lines. I usually pretty print or clean up my formatting with an external editor such as Dreamweaver so I don't believe it was origianlly mixed but you never know, I didn't have the validation errors on 1.5. The editor in WP 2.0 (or the code formatter) will incorrectly generate paragraph tags if it finds something like the following:


    <img src ="./images/bp.png" alt="Brad Peterson" class="albumImage"/><h3>Brad Peterson - The Pharmacist</h3>


    Yes, the headers should be on seperate lines as I know. The 1.5 editor either ignored this or the upgrade removed line feeds I previously had; not sure which. In any case the fix is to pretty-print or format the HTML (or put it in correctly) as the genreated paragraphs are not seen in the WordPress editor. Quite simple and now I am down to the id tag errors which are self imposed.

    Thanks - Trip

  7. SoundTrip
    Member
    Posted 8 years ago #

    Oh--there is no valid reason to repeat an ID on a page. If it repeats, code it so that it's a CLASS, not an ID. ID is for unique items; CLASS is for multiple items.

    Yeah, laziness on my part; slap necessary. I fixed this and the page passes validation.

    Thanks for all the tips everyone. Todd, good luck on the education blog. - Trip

  8. tsguitar
    Member
    Posted 8 years ago #

    Trip:

    This all sounds really funky. And I don't meant to sound defensive, but the code I was seeing was way off and it wasn't clear how WP would have generated that code. WP 2.0 is full of bugs and causes lots of errors, something I have no problem saying.

    I still don't quite understand what fixed your problem, but I hope it's working for you. I'm glad you fixed the CLASS/ID thing. And thanks for the good luck wishes.

  9. SoundTrip
    Member
    Posted 8 years ago #

    Hi TS,

    The editor in WP 2.0 generates </br> and tags whenever it detects a linefeed and/or combination of linefeeds. I was not aware that this was happening and that is what was throwing my HTML output off.

    I've learned that it is important to look at the generated code, or minimally check posts against an xhtml compliance checker to make sure that the code stays in speck.

    Thanks for your help. - Trip

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags