On 30/04/2011 5:24 PM, Philippe Wittenbergh wrote:
On Apr 30, 2011, at 3:19 PM, Jukka K. Korpela wrote:
That doesn't matter, as ID's starting with a leading digit are
not allowed in html4.01.
Right, but this is really a formality - though a validator message
is useful, as it makes the author suspicious. As far as HTML
processing is concerned, browsers don't seem to have problems with
id values starting with a digit, but they raise some issues in
CSS.
I send bogus XHTML on all of my pages on CSS class which the validator
reports as valid XHTML (entitled to use a 'valid XHTML 1.0 icon').
A warning to those following this thread. Do not trust the validator.
Also, do not trust others on CSS discuss to know fully what they are
doing or talking about. Especially me since I'm mainly self learning.
Now to make this part of the thread on-topic for this list.
My commenting on what HTML4.01 says was really nitpicking, in case
you din't notice :-p. Browser don't really care, afaik; and that is
probably one reason why HTML5 doesn't make ID's starting with a digit
invalid.
Philippe. CSS just isn't to style HTML. It can style XML (and text/*
sub-types) and XHTML as well [1] [2].
http://www.w3.org/TR/2002/REC-xhtml1-20020801/#h-4.10
Digits are not forbidden in XML or XHTML.
http://www.w3.org/TR/2002/REC-xhtml1-20020801/#C_8
The CSS selector is only valid when the (leading) digit is
escaped…
Yes, and that makes CSS code somewhat messy, so it's usually best
to avoid id attribute values that start with a digit, if you intend
to use them in CSS.
Sure, I wouldn't advocate it either; I can picture all those flashy
web-apps and friends though, with tons of script generated ID's. Even
then, I would recommend to prefix those ID's.
I see there use for tabular data (ie. databases) which can be script
generated.
but #\34col1 {background: lime;} is valid
Well, technically it is valid, but it does not match id="4col1".
The reason is that since "c" is a hexadecimal digit, "34c" is taken
as a hexadecimal number. To make the selector match id="4col1", you
can write it e.g. as \34 col1 (i.e. with a space after "4").
Right, I intended to type that space there, obviously it didn't go
beyond intention. Blame the weather, or the wave, or something.
Philippe -- Philippe Wittenbergh http://l-c-n.com/
Digits are forbidden at the beginning of id and class selectors since
0~9, and a~f are reserved for hexadecimal notation. This is not because
you can't use CSS to select id and class selector beginning with digits,
since that would make CSS a little less powerful by only working with
HTML. The whitespaces are only needed in identifiers. In other parts of
CSS you can have whitespace or no whitepsace.
http://css-class.com/test/css21testsuite/rgb-colors-escaped-030.xht
I still don't understand why or how CSS can be parsed like this. I
theorized that this may be needed if some precessing of CSS code is
turned into escape sequences.
<!DOCTYPE html>
<style type="text/css">
\0064\0069\0076 { \0062\0061\0063\006B\0067\0072\006F\0075\006E\0064:
\006C\0069\006D\0065 }
</style>
<div>This division should have a lime background since the CSS represent
this <code>div { background: lime }</code>.</div>
[1] http://css-class.com/test/svg/svg-within-xhtml.xml
[2] http://onwebdev.blogspot.com/2010/12/linking-css-and-xml-documents.html
--
Alan Gresley
http://css-3d.org/
http://css-class.com/
______________________________________________________________________
css-discuss [[email protected]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/