CSS: Class error

  • Thread starter Luigi Donatello Asero
  • Start date
D

David Dorward

So, I guess that the validator thinks that "#" is a character of the name
of the class... instead it means that what it follows is the name of the
"id"

Looks like it might be a bug then.
 
E

Els

Michael said:
Luigi said:
What is wrong with this?
.subsubsection#sverige
[snip]

So, what is it, a class? (.susubsection) an id? (#sverige)?
Can't make the two into a hybrid.

Certainly can[1].

Yes, I was entirely mistaken.

[snip explanation]
As for what a 'class error' is, I have no idea. Unless Luigi cares to
mention where (and with what) this error apparently occurred, there's
not much I can add.

I saw in another message of his, that he got that from
http://www.htmlhelp.com/tools/csscheck/ which actually does give that
error (erroneously).
[1] See the simple_selector production in Appendix D.1 Grammar of
the CSS 2 Specification.

<http://www.w3.org/TR/REC-CSS2/grammar.html#x1>

Thanks - that's one of the W3C pages I didn't come across before :)
 
E

Els

David said:
Looks like it might be a bug then.

Or maybe it's because it's a CSS1 checker:
<quote>
Note: CSSCheck is primarily a CSS1 checker. Many CSS2 properties are
supported, but new CSS2 selectors will generate errors.
</quote>

(If I understood appendix B of the CSS1 specs correctly (of which I'm
not sure), only 1 class/id/pseudo-class is allowed per selector in
CSS1)
 
M

Michael Winter

On 26/02/2006 09:11, Els wrote:

[snip]

Yes, but I think I ended up paraphrasing the applicable paragraph. :)
Not intentionally, mind you.

Section 5 (Selectors) doesn't contain any examples of of mixed type
attribute selectors as far as I can see. However, the (normative)
grammar makes it unequivocally clear that they are valid for simple
selectors[1].

Mike


[1] I should point out that the simple_selector production in the
CSS 2 grammar is in error. It was corrected in CSS 2.1 to:

simple_selector
: element_name [ HASH | class | attrib | pseudo ]*
| [ HASH | class | attrib | pseudo ]+
;

The previous production made the selector entirely optional.
That is,

{
/* Declarations */
}

would be valid.
 
M

Michael Winter

On 26/02/2006 09:21, Els wrote:

[snip]
(If I understood appendix B of the CSS1 specs correctly (of which I'm
not sure), only 1 class/id/pseudo-class is allowed per selector in
CSS1)

I'm not quite sure what you're trying to express, here.

.className or #id

but not

#id.className

An id, class, or pseudo-class selector can appear by itself [optionally
combined with an element], but more than one type of attribute selector
cannot be combined.

Or perhaps:

#id.className

but not

.class1.class2

Multiple attribute selector types can be used together, but only one of
each type can be used at once.

As I read it, the grammar permits the latter, but it also places very
tight constraints on the /order/ of simple selector components: element,
id, class, pseudo-class. A simple selector can contain any of these, but
if any are present, they must appear in that order and can only occur
once at most.

The reason why

.subsubsection#sverige a

fails is because the id selector follows the class name.

#sverige.subsubsection a

will be accepted.

Note that the W3C validator doesn't care much for the order, either
because it wasn't meant to be significant (but that fact couldn't be
expressed concisely in the grammar), or due to a bug.

Mike
 
E

Els

Michael said:
On 26/02/2006 09:21, Els wrote:

[snip]
(If I understood appendix B of the CSS1 specs correctly (of which I'm
not sure), only 1 class/id/pseudo-class is allowed per selector in
CSS1)

I'm not quite sure what you're trying to express, here.

.className or #id

but not

#id.className

That's what I figured appendix B is saying.
Apparently it isn't though:
As I read it, the grammar permits the latter, but it also places very
tight constraints on the /order/ of simple selector components: element,
id, class, pseudo-class. A simple selector can contain any of these, but
if any are present, they must appear in that order and can only occur
once at most.

The reason why

.subsubsection#sverige a

fails is because the id selector follows the class name.

#sverige.subsubsection a

will be accepted.

Yes, that CSS1 checker does accept that. I didn't expect that.
Note that the W3C validator doesn't care much for the order, either
because it wasn't meant to be significant (but that fact couldn't be
expressed concisely in the grammar), or due to a bug.

Well, I'll just stick to CSS2.1, which I mostly understand, and
combine that with what works in the browsers. Life can be so easy ;-)
 
J

Jonathan N. Little

Luigi said:
The W3C CSS Validator did not seem to accept
URLs with https and for some reason did not display any results when I tried
to paste the content of the file,
so I used this one instead
http://www.htmlhelp.com/tools/csscheck/
This displayed the error as far as I remember
Afterwards I tried to make many changes in the stylesheet to improve it and
it probably needs be much improved yet


Okay I think I know what is going on here, when Luigi is trying to
specify a A element that is a child of and ELEMENT that is both
CLASS="subssubsection" AND ID="saverige" fails because

..subsubsection#sverige A
^^^^^^^^^^^^^^^^^^^^^^
this is the wrong way to specify the condition as it is being
interpreted as class "subsubsection#sverige" containing an illegal
character '#' thus giving you the "class error", to what you wish Luigi
I think it should be written:

#sverige[class="subsubsection"] a {...}
 
E

Els

Jonathan said:
Luigi said:
The W3C CSS Validator did not seem to accept
URLs with https and for some reason did not display any results when I tried
to paste the content of the file,
so I used this one instead
http://www.htmlhelp.com/tools/csscheck/
This displayed the error as far as I remember
Afterwards I tried to make many changes in the stylesheet to improve it and
it probably needs be much improved yet

Okay I think I know what is going on here, when Luigi is trying to
specify a A element that is a child of and ELEMENT that is both
CLASS="subssubsection" AND ID="saverige" fails because

.subsubsection#sverige A
^^^^^^^^^^^^^^^^^^^^^^
this is the wrong way to specify the condition as it is being
interpreted as class "subsubsection#sverige" containing an illegal
character '#' thus giving you the "class error", to what you wish Luigi
I think it should be written:

#sverige[class="subsubsection"] a {...}

..subsubsection#sverige is actually correct.
Proof:
<http://validator.w3.org/check?verbose=1&uri=http://here.locusmeus.com/temp/idclass.html>
 
L

Luigi Donatello Asero

Michael Winter said:
On 26/02/2006 09:21, Els wrote:

[snip]
(If I understood appendix B of the CSS1 specs correctly (of which I'm
not sure), only 1 class/id/pseudo-class is allowed per selector in
CSS1)

I'm not quite sure what you're trying to express, here.

.className or #id

but not

#id.className

An id, class, or pseudo-class selector can appear by itself [optionally
combined with an element], but more than one type of attribute selector
cannot be combined.

Or perhaps:

#id.className

but not

.class1.class2

Multiple attribute selector types can be used together, but only one of
each type can be used at once.

As I read it, the grammar permits the latter, but it also places very
tight constraints on the /order/ of simple selector components: element,
id, class, pseudo-class. A simple selector can contain any of these, but
if any are present, they must appear in that order and can only occur
once at most.

The reason why

.subsubsection#sverige a

fails is because the id selector follows the class name.

#sverige.subsubsection a

will be accepted.


So is the latter the correct form although the former is tolerated?
Is
#sverige.subsection a=
<a class="subsection" id="sverige"> ?
 
S

Steve Pugh

Luigi Donatello Asero said:
Is
#sverige.subsection a=
<a class="subsection" id="sverige"> ?

No. And surely you've seen enough CSS by now to understand something
as basic as a descendent selector? Ignore the order of the #sverige
and .subsection, would you ask whether "#sverige a" matched <a
id="sverige"> or whether ".subsection a" matched <a
class="subsection">?

#sverige.subsection a
is the selector for
<foo class="subsection" id="sverige"><a>

The selector for <a class="subsection" id="sverige">
would be
a#sverige.subsection

Steve
 
M

Michael Winter

"Michael Winter" <[email protected]> skrev i meddelandet

[snip]
The reason why

.subsubsection#sverige a

fails is because the id selector follows the class name.

#sverige.subsubsection a

will be accepted.

So is the latter the correct form although the former is tolerated?

As far as the grammar for CSS 1 is concerned, yes. For CSS 2 (and
later), the order is not important and the selectors are equivalent.
Is
#sverige.subsection a=
<a class="subsection" id="sverige"> ?

No, see Steve's reply.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top