Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-15-2009, 12:14 PM   PM User | #1
snarf1974
New Coder

 
Join Date: Aug 2008
Location: Liverpool
Posts: 53
Thanks: 37
Thanked 0 Times in 0 Posts
snarf1974 is an unknown quantity at this point
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

snarf1974 is offline   Reply With Quote
Old 05-15-2009, 12:23 PM   PM User | #2
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,827
Thanks: 9
Thanked 685 Times in 679 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
Use a transitional doctype instead?
SB65 is offline   Reply With Quote
Old 05-15-2009, 12:31 PM   PM User | #3
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,699
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Users who have thanked VIPStephan for this post:
snarf1974 (05-15-2009)
Old 05-15-2009, 12:38 PM   PM User | #4
snarf1974
New Coder

 
Join Date: Aug 2008
Location: Liverpool
Posts: 53
Thanks: 37
Thanked 0 Times in 0 Posts
snarf1974 is an unknown quantity at this point
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
snarf1974 is offline   Reply With Quote
Old 05-15-2009, 01:18 PM   PM User | #5
Rowsdower!
Senior Coder

 
Rowsdower!'s Avatar
 
Join Date: Oct 2008
Location: Some say it's everything.
Posts: 2,015
Thanks: 5
Thanked 395 Times in 388 Posts
Rowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura about
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
Rowsdower! is offline   Reply With Quote
Old 05-15-2009, 01:27 PM   PM User | #6
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,827
Thanks: 9
Thanked 685 Times in 679 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
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.
SB65 is offline   Reply With Quote
Old 05-15-2009, 01:32 PM   PM User | #7
Rowsdower!
Senior Coder

 
Rowsdower!'s Avatar
 
Join Date: Oct 2008
Location: Some say it's everything.
Posts: 2,015
Thanks: 5
Thanked 395 Times in 388 Posts
Rowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura about
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
Rowsdower! is offline   Reply With Quote
Old 05-15-2009, 01:59 PM   PM User | #8
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,699
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:59 PM.


Advertisement
Log in to turn off these ads.