Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Aug 2008
    Location
    Liverpool
    Posts
    53
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Question ordered list invalid markup when adding value=""

    Hi,

    Not sure if there is a simple workaround for this.

    I've got an ordered list, but somewhere in the list I want to skip a number, like so:

    Code:
    <ol>
    <li>blah</li>
    <li>blah</li>
    <li>blah</li>
    <li value="5">blah</li>
    <li>blah</li>
    </ol>
    It looked like this was fine, but it came back as invalid XHTML 1.0 Strict!
    Is there anyway to negate this error?

    Many Thanks


  • #2
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,957
    Thanks
    9
    Thanked 727 Times in 721 Posts
    Use a transitional doctype instead?

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,859
    Thanks
    6
    Thanked 1,028 Times in 1,001 Posts
    As you notice the value attribute (and the start attribute) for lists is not valid. It used to be but has been marked as deprecated for HTML 4 and XHTML in favor of CSS counters.

    However, implementation is incomplete, I think. Especially Internet Explorer is gonna be our best friend again. You may be able to manipulate it in a cross-browser way with JavaScript (maybe even as addition to the CSS way to complement for devices that don’t support it) or just don’t care about the failure to validate in this case (even the W3C says that documents don’t necessarily have to be 100% valid as long as they are well formed).

    However, the worst thing you could do is change the doctype (for example to “transitional”) just to get a “valid” label. That’s the wrong approach! Strict is the only correct option and I’d stongly ask you to stick to it.

  • Users who have thanked VIPStephan for this post:

    snarf1974 (05-15-2009)

  • #4
    New Coder
    Join Date
    Aug 2008
    Location
    Liverpool
    Posts
    53
    Thanks
    37
    Thanked 0 Times in 0 Posts
    Thanks VIPStephan, I agree that xhtml 1.0 Strict! is definately the best option, and transitional shouldn't be entertained.

    I'll probably not go down the javascript route, but thanks for the swift response

  • #5
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    What about something like this:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>skip number</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    </head>
    <body>
    <ol>
    <li>blah</li>
    <li>blah</li>
    <li>blah</li>
    <li style="visibility:hidden;margin-top:-1.25em;">skipping this number</li>
    <li>blah</li>
    <li>blah</li>
    </ol>
    </body>
    </html>
    This might not be "semantic" enough for some people but it seems like this should work...
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #6
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,957
    Thanks
    9
    Thanked 727 Times in 721 Posts
    Ok, I realise I'm arguing against a number of people far more experienced than me here, but isn't hiding a field or using javascript adding unnecessary complexity?

    And isn't the transitional doctype designed precisely for this sort of occurrence?

    I've read all the stuff about strict doctypes encouraging proper markup, separation of style from content and all that, but using a transitional doctype doesn't prevent you from doing this.

    Are there any real-world disadvantages to using transtional instead of strict?

    Off to get my tin helmet now....
    Seriously, I'm not trying to provoke a big row on this one.

  • #7
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Quote Originally Posted by SB65 View Post
    Ok, I realise I'm arguing against a number of people far more experienced than me here, but isn't hiding a field or using javascript adding unnecessary complexity?

    And isn't the transitional doctype designed precisely for this sort of occurrence?

    I've read all the stuff about strict doctypes encouraging proper markup, separation of style from content and all that, but using a transitional doctype doesn't prevent you from doing this.

    Are there any real-world disadvantages to using transtional instead of strict?

    Off to get my tin helmet now....
    Seriously, I'm not trying to provoke a big row on this one.
    Beats me, I'm just trying to provide a solution within the parameters set by the OP. I aim for strict wherever possible but in a case like this I'd probably consider just downgrading to transitional, but that's me... Different strokes for different folks!
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #8
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,859
    Thanks
    6
    Thanked 1,028 Times in 1,001 Posts
    Quote Originally Posted by SB65 View Post
    Ok, I realise I'm arguing against a number of people far more experienced than me here, but isn't hiding a field or using javascript adding unnecessary complexity?

    And isn't the transitional doctype designed precisely for this sort of occurrence?
    Well, actually no, the transitional doctype wan’t invented to resort back to non-standard code just to get a “valid” document. Its original purpose was to ease the transition from documents coded after old, non-standard methods to a standards compliant markup. It provides a way to apply at least something to old websites that used to have no document type definition at all so the HTML parser knows what actually to parse. For this reason a transitional doctype won’t penalize the use of deprecated elements or attributes. But the actual definition of true valid HTML is the strict definition.

    In a nutshell: Newly created websites should always get the strict doctype. The transitional doctype is only for already existing websites that are in the transition of old non-standard code (with no doctype) to standards compliant code.

    As to the JavaScript issue: I wasn’t actually thinking of hiding a field with JavaScript but more in the way of changing the counter of the list items through JS or dynamically adding/changing the numbers with JS, skipping one value (where the CSS method wouldn’t apply).

    Of course this is a little more complex than using deprecated but working attributes but on the other hand it’s a lot cleaner and more modularized (if you make use of unobtrusive JavaScript).

    However, at the end of the day it’s totally your choice what you do. You aren’t breaking any laws by writing tag soup.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •