467,211 Members | 1,257 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,211 developers. It's quick & easy.

Class attribute values


While the values of 'id' and 'name' attributes include restrictions on the
use of characters such as beginning with a letter, the values of the
'class' attribute define no restriction as I can find.

Thus the use of:

class="thumbedImage 0.4"

is permitted, and could be used as an attribute in IMG elements to identify
images whose sizes I want to change dynamically with the loading of the
document body through a script function call, as the "onload" attribute is
not allowed for IMG elements in the specification.
(The script function essentially would get a list of image element nodes
from the document body, examine the class attribute values for the presence
of the correct values, and then make changes to those images having the
required values.)

Is there anyone whose understanding of the specification differs from this
understanding?
Nov 7 '05 #1
  • viewed: 1852
Share:
13 Replies
Patient Guy <Pa*********@nowhere.to.be.found.com> wrote:
While the values of 'id' and 'name' attributes include restrictions on the
use of characters such as beginning with a letter, the values of the
'class' attribute define no restriction as I can find.

Thus the use of:

class="thumbedImage 0.4"

is permitted,


The above assigns two classes to the element, "thumbedImage" and "0.4",
the latter is not permitted since class names are not allowed to start
with a digit: http://www.w3.org/TR/CSS21/syndata.html#q6

--
Spartanicus
Nov 7 '05 #2
On Mon, 07 Nov 2005 07:27:04 GMT, Patient Guy
<Pa*********@nowhere.to.be.found.com> wrote:
While the values of 'id' and 'name' attributes include restrictions on the
use of characters such as beginning with a letter, the values of the
'class' attribute define no restriction as I can find.

Thus the use of:

class="thumbedImage 0.4"

is permitted, and could be used as an attribute in IMG elements to identify
images whose sizes I want to change dynamically with the loading of the
document body through a script function call, as the "onload" attribute is
not allowed for IMG elements in the specification. ....Is there anyone whose understanding of the specification differs from this
understanding?

Well, I couldn't immediately find something prohibiting that. However:

class="thumbedImage 0.4" assigns the classes "thumbedImage" and "0.4"
to the element.

In CSS, img.0.4 { ... } would refer to images having the class 0 and
the class 4.

In fact in CSS: "identifiers (including element names, classes, and IDs
in selectors) can contain only the characters [A-Za-z0-9] and ISO 10646
characters 161 and higher, plus the hyphen (-); they cannot start with a
hyphen or a digit."

Even if you can use periods in HTML class-names, it seems to me that it
would be inadvisable.

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Nov 7 '05 #3
Spartanicus wrote:
The above assigns two classes to the element, "thumbedImage" and "0.4",
the latter is not permitted since class names are not allowed to start
with a digit: http://www.w3.org/TR/CSS21/syndata.html#q6


In HTML, class names *are* allowed to start with a digit. However, if you
choose to use class names that start with a digit, you can't select them
using the CSS "dot-class" selector -- that is classes that don't start
with a letter aren't particularly useful for styling, but can be used for
general purpose element subclassing.)

(Of course you can select them in CSS using *[class~="0.4"], though
browser support for this syntax is less widespread.)

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Nov 7 '05 #4
Toby Inkster <us**********@tobyinkster.co.uk> wrote:
The above assigns two classes to the element, "thumbedImage" and "0.4",
the latter is not permitted since class names are not allowed to start
with a digit: http://www.w3.org/TR/CSS21/syndata.html#q6


In HTML, class names *are* allowed to start with a digit.


You're almost clever. Had you been really clever you might have noticed
that I didn't mention HTML and referenced the CSS rules.

--
Spartanicus
Nov 7 '05 #5
Spartanicus wrote:
You're almost clever. Had you been really clever you might have noticed
that I didn't mention HTML and referenced the CSS rules.


And had you been really clever you might have noticed that this is
ciwa.*html*, that the context of the question was HTML and JavaScript, and
that, as Toby pointed out, you can reference classes that start with a
number in CSS - you just have to do so via an attribute selector.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Nov 7 '05 #6
Spartanicus wrote:
You're almost clever. Had you been really clever you might have noticed
that I didn't mention HTML and referenced the CSS rules.


What I *did* notice was that the post to which you were replying gave
an HTML (not CSS) example, and didn't mention CSS at all.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Nov 8 '05 #7
On Mon, 07 Nov 2005 22:36:02 GMT, Spartanicus <in*****@invalid.invalid>
wrote:
Toby Inkster <us**********@tobyinkster.co.uk> wrote:
The above assigns two classes to the element, "thumbedImage" and "0.4",
the latter is not permitted since class names are not allowed to start
with a digit: http://www.w3.org/TR/CSS21/syndata.html#q6
In HTML, class names *are* allowed to start with a digit.
You're almost clever. Had you been really clever you might have noticed
that I didn't mention HTML and referenced the CSS rules.


Now my dear Spartanicus, you are just plain dumb; go put on your white
"dumb ass" cone hat and sit tight in a corner with that one on for the
coming 24 hours.

--
Rex
Nov 8 '05 #8
Toby Inkster <us**********@tobyinkster.co.uk> wrote:
You're almost clever. Had you been really clever you might have noticed
that I didn't mention HTML and referenced the CSS rules.


What I *did* notice was that the post to which you were replying gave
an HTML (not CSS) example, and didn't mention CSS at all.


So it did, apologies for my remark.

--
Spartanicus
Nov 8 '05 #9
David Dorward <do*****@yahoo.com> wrote:
You're almost clever. Had you been really clever you might have noticed
that I didn't mention HTML and referenced the CSS rules.
And had you been really clever you might have noticed that this is
ciwa.*html*


And alt.html (where it shows up here). Btw, I undid your attempt to
remove alt.html from this thread.
, that the context of the question was HTML and JavaScript,
That I indeed missed.
and
that, as Toby pointed out, you can reference classes that start with a
number in CSS - you just have to do so via an attribute selector.


That doesn't change the fact that class names cannot start with a digit
according to the CSS syntax rules.

--
Spartanicus
Nov 8 '05 #10
With neither quill nor qualm, Jan Roland Eriksson quothed:
On Mon, 07 Nov 2005 22:36:02 GMT, Spartanicus <in*****@invalid.invalid>
wrote:
Toby Inkster <us**********@tobyinkster.co.uk> wrote:
The above assigns two classes to the element, "thumbedImage" and "0.4",
the latter is not permitted since class names are not allowed to start
with a digit: http://www.w3.org/TR/CSS21/syndata.html#q6In HTML, class names *are* allowed to start with a digit.

You're almost clever. Had you been really clever you might have noticed
that I didn't mention HTML and referenced the CSS rules.


Now my dear Spartanicus, you are just plain dumb; go put on your white
"dumb ass" cone hat and sit tight in a corner with that one on for the
coming 24 hours.


Hah, what do you know? "Dumb ass hats" don't come in white. However,
"dunce caps" may be procured in a light eggshell.

--
Neredbojias
Contrary to popular belief, it is believable.
Nov 8 '05 #11
With neither quill nor qualm, Spartanicus quothed:

....
That doesn't change the fact that class names cannot start with a digit
according to the CSS syntax rules.


And that, as far as I'm concerned, was the main point.

--
Neredbojias
Contrary to popular belief, it is believable.
Nov 8 '05 #12
Neredbojias wrote:
With neither quill nor qualm, Jan Roland Eriksson quothed:

Now my dear Spartanicus, you are just plain dumb; go put on
your white "dumb ass" cone hat and sit tight in a corner with
that one on for the coming 24 hours.


Hah, what do you know? "Dumb ass hats" don't come in white.
However, "dunce caps" may be procured in a light eggshell.


Assclown hats do (but they're not conical):

http://lessthanfake.tripod.com/siteb...builderpicture
s/acaw.jpg
--
Blinky
Killing all Google Groups posts.
http://blinkynet.net/comp/uip5.html
Nov 8 '05 #13
Toby Inkster wrote:
Spartanicus wrote:
The above assigns two classes to the element, "thumbedImage" and "0.4",
the latter is not permitted since class names are not allowed to start
with a digit: http://www.w3.org/TR/CSS21/syndata.html#q6


In HTML, class names *are* allowed to start with a digit. However, if you
choose to use class names that start with a digit, you can't select them
using the CSS "dot-class" selector...


Yes you can, it's just not as clear as the attribute selector. This
works for the class name "0.4"

..\30\.4 { color: green; }

(note: 30 is the hex code point for digit 0)

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Nov 11 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Krzysztof Stachlewski | last post: by
3 posts views Thread by gry@ll.mit.edu | last post: by
16 posts views Thread by Stoic | last post: by
2 posts views Thread by Ewald R. de Wit | last post: by
reply views Thread by keith bannister via .NET 247 | last post: by
5 posts views Thread by crystalattice | last post: by
3 posts views Thread by antred | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.