WordPress.org

Ready to get started?Download WordPress

Forums

Comment styling & Validation (15 posts)

  1. Jinsan
    Member
    Posted 9 years ago #

    1) Should comments or a page with comments validate - if so, why would the following be invalid:

    http://sekhu.net/wp/2005/02/01/how-many/#comments
    http://validator.w3.org/check?verbose=1&uri=http%3A//sekhu.net/wp/2005/02/01/how-many/%23comments

    Is this to do with how it was coded? What can I do to "fix" the "problem"?

    2) You'll note on the comments page the number of the post is on the left outside of the content area - I'd like it to be:

    a) inside the content area
    b) just after the time and date by perhaps a few spaces
    c) to be sequential to the site rather than the post - that is to say, if post 1 contains 2 comments, they are numbred 1 and 2, with subsequent posts containing comments to continue the count in ascending order.

    Thanks in advance

  2. Lorelle
    Member
    Posted 9 years ago #

    Jinsan, when using a "span" it must be inside of a paragraph or div. It can't cross div closing tags or paragraph closing tags or any other containers. It must be within a container.

    You have:

    <span class="commentbody"><p>i heard the butler got bizee...

    and it needs to be:

    <p><span class="commentbody">I heard the bulter...

  3. Jinsan
    Member
    Posted 9 years ago #

    O_o - but I didn't code it that way, it was pre done. Interesting. I'll see if I can change it guess. Thanks

  4. ifelse
    Member
    Posted 9 years ago #

    ..or you can use divs instead of spans i.e.
    <div class="commentbody"><p>

    Change this within the theme's comment file.

  5. Jinsan
    Member
    Posted 9 years ago #

    yeap i thought hmm what if I...and it woked - just out of curiosity, was there a reason for using span, rather than div?

    Any tips for question 2) phu?

  6. ifelse
    Member
    Posted 9 years ago #

    just out of curiosity, was there a reason for using span, rather than div?
    I forget:-)
    Any tips for question 2) phu?
    The numbering of comments is done implicitly as the comments are defined as an ordered list. Unfortunately, most browsers (AFAIK) don't provide the css support required to style these. Hence, your best bet is to do the following:

    1) suppress the numeric display (list-style-type:none).
    2) Manually keep a counter variable that increments through the comments loop i.e. $commentcount++.
    3) Using this counter, mark this up as <span class="commentcount"><?php echo $commentcount; ?></span><br />
    4) Style this appropriately in your css.

  7. Lorelle
    Member
    Posted 9 years ago #

    spans are meant for "inline" styles, which means a ~~temporary little style~~ that comes on and goes off inside of a container. A div is literally a "division" of styles, better known as a container. It holds a group of styles together.

    They both basically do the same thing but work a little differently. In some older browsers, closing a div meant creating a line break - end of container, next! Closing a span means...nothing. It's just closed and go about your business. In the simplist of terms.

  8. Jinsan
    Member
    Posted 9 years ago #

    I ended up using:

    <?php $count = 0; foreach ($comments as $comment): $count++; ?><div class="count">#<?php echo $count; ?>:</div>

    This creates the count, but doesn't do it sequentially for the site, and instead individually for each post. It's not what I wanted, but I guess it's better than nothing.

    It's coming together, slowly but surely:)

    I'm still get invalidiation though :(

  9. ifelse
    Member
    Posted 9 years ago #

    "This creates the count, but doesn't do it sequentially for the site"
    Ahh... Didn't read that part:-)

    Why don't you use the comment_id which is a unique sequentially allocated identifier (eg. <?php comment_ID(); ?>)?

  10. @Lorelle, re: div vs. span - A light bulb just went off in my head. Thanks! :D

  11. Jinsan
    Member
    Posted 9 years ago #

    would I replace the comment count call with <?php comment_ID(); ?>?

    EDIT: Ok that's got the sequence sorted. Now I'm trying to style the bugger and I still get validation errors.

    I tried adding div class="count" before and after the suggest tag, but that again causes validation errors

  12. ifelse
    Member
    Posted 9 years ago #

    Yep e.g.
    <?php foreach ($comments as $comment): ?><div class="count">#<?php comment_ID(); ?>:</div>

  13. Jinsan
    Member
    Posted 9 years ago #

    Yep, got that, got it working, validation is starting to piss me off though :(

    http://validator.w3.org/check?uri=http%3A%2F%2Fsekhu.net%2Fwp%2F2005%2F02%2F01%2Fhow-many%2F%23comments&charset=%28detect+automatically%29&doctype=%28detect+automatically%29&verbose=1

    Says it doesn't allow divs, so I tried span, and it doesn't allow span so I tried li, and it still spews errors.

  14. Lorelle
    Member
    Posted 9 years ago #

    By messing with the list order stuff, you've:

    assuming missing "li" start-tag

    screwed up your lists. Check your list nesting.

    Remember, for every action there is an equal and opposite reaction. This is the law of the world, not just CSS and web page design. And it works. The more you screw things up, move away from the tried and true to make things work in the way you WANT them to work not the way they were probably already working before you started....the more borked they become.

    You are walking proof of this theory right now, J. ;-)

  15. Jinsan
    Member
    Posted 9 years ago #

    Well just to clarify I didn't touch the list themselves, I added and removed the decimel using the CSS. I made no actual changes to the list in anyway. After much thinking I have got it to work.

    Thanks for your help ifelse - I wasn't aware it was the kubrick template for comments, could have played with that first :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.