• Resolved moses08

    (@moses08)


    Hey all,

    I’m trying to get my block to validate correctly at https://validator.w3.org/

    For reference, my blog URL is https://www.nfldraftdirt.com

    I’m looking at the errors that the validator is giving me and I know the solution but I can’t implement it.

    The problem is that I’m opening an anchor tag before I close a strong tag. I can’t figure out how to close the strong tag before opening the anchor tag because it is all done dynamically. Here is the code in question:

    <div class="entrymeta">
    Posted <?php
    the_time('F j, Y ');
    $comments_img_link= <img src="' . get_stylesheet_directory_uri() . /images/comments.gif" title="comments" alt="*" /><strong>;

    comments_popup_link($comments_img_link .Comments(0)', $comments_img_link .' Comments(1)', $comments_img_link . ' Comments(%)');
    edit_post_link(__(' Edit'));?>
    </strong> </div>

    Any suggestions? Also, if you know how to solve any of the other validation problems I would more then appreciate it.

    Thanks a lot!

Viewing 8 replies - 1 through 8 (of 8 total)
  • In HTML (and XHTML), tags have to be nested (opened and close) in order of occurrence:

    INCORRECT:
    <strong><a href="whatever">some text</strong></a>
    CORRECT:
    <strong><a href="whatever">some text</a></strong>

    In your code above, you’re opening the strong tage after the image. Just open it where you really want the strong tag to start, and close it where it should logically close.

    Thread Starter moses08

    (@moses08)

    That’s what I figured out but I don’t know much about PHP so I’m having trouble implementing it.

    That’s nothing to do with PHP, it’s HTML. But it’s a habit you must learn. Tags must be nested and not overlapping. And all tags must be closed. Tags that stand alone (IMG, BR, HR) must have a trailing slash.

    Thread Starter moses08

    (@moses08)

    I understand how to write XHTML compliant webpages but I can’t figure out how to close the strong tag before the anchor tag. The code looks like PHP to me. What exactly do I need to do to close the strong tag before the anchor tag begins?

    Is this code you wrote yourself? It’s very odd looking. Ahhh…I see, You’re trying to replace the regular text with an actual image link. Your problem is that you’re using the image itself to set the boldness of the text, Don’t do that. Do this:

    <div class="entrymeta">
    Posted <?php the_time('F j, Y ');
    $comments_img_link = <img src="' . get_stylesheet_directory_uri() . /images/comments.gif" title="comments" alt="*" />;
    comments_popup_link($comments_img_link .Comments(0)', $comments_img_link .' Comments(1)', $comments_img_link . ' Comments(%)');
    edit_post_link(__(' Edit'));?>
    </div>

    Now, in your CSS, just put in:

    div.entrymeta a {
    font-style:bold;
    }

    The point of CSS is to avoid extra markup.

    …and by the way -fix that and *all* the errors go away – they’re all referencing this one issue.

    Thread Starter moses08

    (@moses08)

    Thanks a lot! One of my main issues was that I was editing the wrong file so any changes I made weren’t even being reflected. I finally got it working. Thanks again!

    Maybe mark this as resolved then, thanks?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Validation Problems’ is closed to new replies.