CSS: Class error

Discussion in 'HTML' started by Luigi Donatello Asero, Feb 25, 2006.

  1. What is wrong with this?
    ..subsubsection#sverige A { background-color: #99ffcc;
    background-image:none;
    color: #000000; display: block; text-align:center;}

    I get a "class error"



    --
    Luigi Donatello Asero
    https://www.scaiecat-spa-gigi.com/de/uebersetzung.php
    今天二零零六年二月二å五日
    星期六
    Luigi Donatello Asero, Feb 25, 2006
    #1
    1. Advertising

  2. Luigi Donatello Asero

    Jimmy Guest

    Luigi Donatello Asero wrote:
    > What is wrong with this?
    > .subsubsection#sverige A { background-color: #99ffcc;
    > background-image:none;
    > color: #000000; display: block; text-align:center;}
    >
    > I get a "class error"
    >
    >
    >


    weird...

    try adding a space:

    ..subsubsection #sverige A

    {
    background-color: #99ffcc;
    background-image:none;
    color: #000000;
    display: block;
    text-align:center;
    }
    Jimmy, Feb 26, 2006
    #2
    1. Advertising

  3. Luigi Donatello Asero

    Els Guest

    Luigi Donatello Asero wrote:

    > What is wrong with this?
    > .subsubsection#sverige


    > I get a "class error"


    Of course you do.

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

    --
    Els http://locusmeus.com/
    Els, Feb 26, 2006
    #3
  4. "Els" <> skrev i meddelandet
    news:1xxw5g6a8q2el$...
    > Luigi Donatello Asero wrote:
    >
    > > What is wrong with this?
    > > .subsubsection#sverige

    >
    > > I get a "class error"

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



    "subsubsection" should be the class and "sverige" the id which belongs to
    the class "subsubsection" and which I want to define.


    --
    Luigi Donatello Asero
    https://www.scaiecat-spa-gigi.com/sv/boende-i-italien.php
    Write in peace for peace
    Luigi Donatello Asero, Feb 26, 2006
    #4
  5. Luigi Donatello Asero

    Els Guest

    Luigi Donatello Asero wrote:

    > "Els" <> skrev i meddelandet
    > news:1xxw5g6a8q2el$...
    >> Luigi Donatello Asero wrote:
    >>
    >>> What is wrong with this?
    >>> .subsubsection#sverige

    >>
    >>> I get a "class error"

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

    >
    > "subsubsection" should be the class and "sverige" the id which belongs to
    > the class "subsubsection" and which I want to define.


    Then just use #sverige. There is only one element with id 'sverige' on
    the page (I hope!), so the class need not be mentioned.

    --
    Els http://locusmeus.com/
    Els, Feb 26, 2006
    #5
  6. "Luigi Donatello Asero" <> skrev i meddelandet
    news:wx7Mf.46209$...
    >
    > "Els" <> skrev i meddelandet
    > news:1xxw5g6a8q2el$...
    > > Luigi Donatello Asero wrote:
    > >
    > > > What is wrong with this?
    > > > .subsubsection#sverige

    > >
    > > > I get a "class error"

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

    >
    >
    > "subsubsection" should be the class and "sverige" the id which belongs to
    > the class "subsubsection" and which I want to define.



    In theory there could have been another id which is called "sverige" as
    well but belongs to a different class, so I guess that it is always safer to
    write both the class and the id. The id is a child of the class.

    --
    Luigi Donatello Asero
    https://www.scaiecat-spa-gigi.com/sv/boende-i-italien.php
    今天二零零六年二月二åå…­æ—¥
    星期日
    Luigi Donatello Asero, Feb 26, 2006
    #6
  7. Luigi Donatello Asero

    Els Guest

    Luigi Donatello Asero wrote:

    > "Luigi Donatello Asero" <> skrev i meddelandet
    > news:wx7Mf.46209$...
    >>
    >> "Els" <> skrev i meddelandet
    >> news:1xxw5g6a8q2el$...
    >>> Luigi Donatello Asero wrote:
    >>>
    >>> > What is wrong with this?
    >>> > .subsubsection#sverige
    >>>
    >>> > I get a "class error"
    >>>
    >>> Of course you do.
    >>>
    >>> So, what is it, a class? (.susubsection) an id? (#sverige)?
    >>> Can't make the two into a hybrid.

    >>
    >>
    >> "subsubsection" should be the class and "sverige" the id which belongs to
    >> the class "subsubsection" and which I want to define.

    >
    > In theory there could have been another id which is called "sverige" as


    No, in theory[1] there couldn't be. In practice there could be, but it
    would be wrong practice.

    > well but belongs to a different class, so I guess that it is always safer to
    > write both the class and the id. The id is a child of the class.


    If the element with the id is a child of the element with the class,
    as in <div class="subsubsection"><p id="sverige">, then write it as
    ..subsubsection #sverige.

    _________
    [1] theory based on assumption that you try to follow the W3C
    recommendations

    --
    Els http://locusmeus.com/
    Els, Feb 26, 2006
    #7
  8. "Els" <> skrev i meddelandet
    news:u4ap4gtdc22c$...
    > Luigi Donatello Asero wrote:
    >
    > > "Els" <> skrev i meddelandet
    > > news:1xxw5g6a8q2el$...
    > >> Luigi Donatello Asero wrote:
    > >>
    > >>> What is wrong with this?
    > >>> .subsubsection#sverige
    > >>
    > >>> I get a "class error"
    > >>
    > >> Of course you do.
    > >>
    > >> So, what is it, a class? (.susubsection) an id? (#sverige)?
    > >> Can't make the two into a hybrid.

    > >
    > > "subsubsection" should be the class and "sverige" the id which belongs

    to
    > > the class "subsubsection" and which I want to define.

    >
    > Then just use #sverige. There is only one element with id 'sverige' on
    > the page (I hope!), so the class need not be mentioned.
    >
    > --
    > Els http://locusmeus.com/



    I have not checked up, yet whether there is only one "id" or not which is
    called "Sverige" but why should it be an error to specify both the class
    which is the parent and the "id" which is the child?

    --
    Luigi Donatello Asero
    https://www.scaiecat-spa-gigi.com/sv/boende-i-italien.php
    今天二零零六年二月二åå…­æ—¥
    星期日
    Luigi Donatello Asero, Feb 26, 2006
    #8
  9. "Els" <> skrev i meddelandet
    news:721fru3nawng.i7mkzpmweoxb$...
    > Luigi Donatello Asero wrote:
    >
    > > "Luigi Donatello Asero" <> skrev i meddelandet
    > > news:wx7Mf.46209$...
    > >>
    > >> "Els" <> skrev i meddelandet
    > >> news:1xxw5g6a8q2el$...
    > >>> Luigi Donatello Asero wrote:
    > >>>
    > >>> > What is wrong with this?
    > >>> > .subsubsection#sverige
    > >>>
    > >>> > I get a "class error"
    > >>>
    > >>> Of course you do.
    > >>>
    > >>> So, what is it, a class? (.susubsection) an id? (#sverige)?
    > >>> Can't make the two into a hybrid.
    > >>
    > >>
    > >> "subsubsection" should be the class and "sverige" the id which belongs

    to
    > >> the class "subsubsection" and which I want to define.

    > >
    > > In theory there could have been another id which is called "sverige" as

    >
    > No, in theory[1] there couldn't be. In practice there could be, but it
    > would be wrong practice.


    Do you mean that W3 recommends to use only one "id" for each page
    regardless of whether it belongs to the same class or not?

    > > well but belongs to a different class, so I guess that it is always

    safer to
    > > write both the class and the id. The id is a child of the class.

    >
    > If the element with the id is a child of the element with the class,
    > as in <div class="subsubsection"><p id="sverige">, then write it as
    > .subsubsection #sverige.



    What does "p" stand here for?
    Well,
    ..subsubsection#sverige was what gave an error, wasn´t it?


    --
    Luigi Donatello Asero
    https://www.scaiecat-spa-gigi.com/sv/boende-i-italien.php
    今天二零零六年二月二åå…­æ—¥
    星期日
    Luigi Donatello Asero, Feb 26, 2006
    #9
  10. Luigi Donatello Asero

    Els Guest

    Luigi Donatello Asero wrote:

    >>>>> What is wrong with this?
    >>>>> .subsubsection#sverige
    >>>>>
    >>>>> I get a "class error"
    >>>>
    >>>> Of course you do.
    >>>>
    >>>> So, what is it, a class? (.susubsection) an id? (#sverige)?
    >>>> Can't make the two into a hybrid.
    >>>
    >>> "subsubsection" should be the class and "sverige" the id which belongs
    >>> to the class "subsubsection" and which I want to define.

    >>
    >> Then just use #sverige. There is only one element with id 'sverige' on
    >> the page (I hope!), so the class need not be mentioned.

    >
    > I have not checked up, yet whether there is only one "id" or not which is
    > called "Sverige" but why should it be an error to specify both the class
    > which is the parent and the "id" which is the child?


    Because they are names to identify elements. One element with two
    names, is not a child of itself. Is Asero a child of Donatello which
    is a child of Luigi? No, they all refer to the same person.

    If you write <div class="foo" id="bar">, you are giving two names to
    one element. This is very much okay, and certainly has its use.
    But you can't say that #bar is a child of .foo, because it's one and
    the same element they refer to.

    --
    Els http://locusmeus.com/
    Els, Feb 26, 2006
    #10
  11. Luigi Donatello Asero

    Els Guest

    Luigi Donatello Asero wrote:

    >> If the element with the id is a child of the element with the class,
    >> as in <div class="subsubsection"><p id="sverige">, then write it as
    >> .subsubsection #sverige.

    >
    > What does "p" stand here for?


    Paragraph. It's an example, Luigi, I didn't take it from your website,
    it's entirely by my personal choice that I picked a paragraph element
    to pose as the child of a div with a class 'subsubsection'.

    --
    Els http://locusmeus.com/
    Els, Feb 26, 2006
    #11
  12. Els wrote:

    > Then just use #sverige. There is only one element with id 'sverige' on
    > the page (I hope!), so the class need not be mentioned.


    The same stylesheet might be used with multiple documents with an element of
    id "sverige" but different pages could have different classes assigned to
    that element.

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Feb 26, 2006
    #12
  13. Luigi Donatello Asero wrote:

    > What is wrong with this?
    > .subsubsection#sverige A { background-color: #99ffcc;
    > background-image:none;
    > color: #000000; display: block; text-align:center;}
    >
    > I get a "class error"


    From what? The W3C CSS Validator doesn't throw such an error on that code.

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Feb 26, 2006
    #13
  14. "Els" <> skrev i meddelandet
    news:...
    > Luigi Donatello Asero wrote:
    >
    > >>>>> What is wrong with this?
    > >>>>> .subsubsection#sverige
    > >>>>>
    > >>>>> I get a "class error"
    > >>>>
    > >>>> Of course you do.
    > >>>>
    > >>>> So, what is it, a class? (.susubsection) an id? (#sverige)?
    > >>>> Can't make the two into a hybrid.
    > >>>
    > >>> "subsubsection" should be the class and "sverige" the id which belongs
    > >>> to the class "subsubsection" and which I want to define.
    > >>
    > >> Then just use #sverige. There is only one element with id 'sverige' on
    > >> the page (I hope!), so the class need not be mentioned.

    > >
    > > I have not checked up, yet whether there is only one "id" or not which

    is
    > > called "Sverige" but why should it be an error to specify both the class
    > > which is the parent and the "id" which is the child?

    >
    > Because they are names to identify elements. One element with two
    > names, is not a child of itself. Is Asero a child of Donatello which
    > is a child of Luigi? No, they all refer to the same person.
    >
    > If you write <div class="foo" id="bar">, you are giving two names to
    > one element. This is very much okay, and certainly has its use.
    > But you can't say that #bar is a child of .foo, because it's one and
    > the same element they refer to.


    Why did I get a class error then?


    --
    Luigi Donatello Asero
    https://www.scaiecat-spa-gigi.com/sv/boende-i-italien.php
    今天二零零六年二月二åå…­æ—¥
    星期日
    Luigi Donatello Asero, Feb 26, 2006
    #14
  15. "David Dorward" <> skrev i meddelandet
    news:dtr1ph$7l4$1$...
    > Els wrote:
    >
    > > Then just use #sverige. There is only one element with id 'sverige' on
    > > the page (I hope!), so the class need not be mentioned.

    >
    > The same stylesheet might be used with multiple documents with an element

    of
    > id "sverige" but different pages could have different classes assigned to
    > that element.


    It sounds reasonable.
    So, actually, it is a good thing to use both the class and the id to
    identify the element
    "sverige" in question.


    --
    Luigi Donatello Asero
    https://www.scaiecat-spa-gigi.com/it/svezia.html
    今天二零零六年二月二åå…­æ—¥
    星期日
    Luigi Donatello Asero, Feb 26, 2006
    #15
  16. "David Dorward" <> skrev i meddelandet
    news:dtr1ro$7su$1$...
    > Luigi Donatello Asero wrote:
    >
    > > What is wrong with this?
    > > .subsubsection#sverige A { background-color: #99ffcc;
    > > background-image:none;
    > > color: #000000; display: block; text-align:center;}
    > >
    > > I get a "class error"

    >
    > From what? The W3C CSS Validator doesn't throw such an error on that code.


    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


    --
    Luigi Donatello Asero
    https://www.scaiecat-spa-gigi.com/sv/faktaomitalien.php
    今天二零零六年二月二åå…­æ—¥
    星期日
    Luigi Donatello Asero, Feb 26, 2006
    #16
  17. "Luigi Donatello Asero" <> skrev i meddelandet
    news:M28Mf.46215$...
    >
    > "David Dorward" <> skrev i meddelandet
    > news:dtr1ro$7su$1$...
    > > Luigi Donatello Asero wrote:
    > >
    > > > What is wrong with this?
    > > > .subsubsection#sverige A { background-color: #99ffcc;
    > > > background-image:none;
    > > > color: #000000; display: block; text-align:center;}
    > > >
    > > > I get a "class error"

    > >
    > > From what? The W3C CSS Validator doesn't throw such an error on that

    code.
    >
    > 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



    "Error: Classes may contain only the characters A-Z, a-z, 0-9, Unicode
    161-255, hyphens, or escaped Unicode characters as numeric codes."


    --
    Luigi Donatello Asero
    https://www.scaiecat-spa-gigi.com/sv/faktaomitalien.php
    今天二零零六年二月二åå…­æ—¥
    星期日
    Luigi Donatello Asero, Feb 26, 2006
    #17
  18. "Luigi Donatello Asero" <> skrev i meddelandet
    news:A68Mf.46216$...
    >
    > "Luigi Donatello Asero" <> skrev i meddelandet
    > news:M28Mf.46215$...
    > >
    > > "David Dorward" <> skrev i meddelandet
    > > news:dtr1ro$7su$1$...
    > > > Luigi Donatello Asero wrote:
    > > >
    > > > > What is wrong with this?
    > > > > .subsubsection#sverige A { background-color: #99ffcc;
    > > > > background-image:none;
    > > > > color: #000000; display: block; text-align:center;}
    > > > >
    > > > > I get a "class error"
    > > >
    > > > From what? The W3C CSS Validator doesn't throw such an error on that

    > code.
    > >
    > > 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

    >
    >
    > "Error: Classes may contain only the characters A-Z, a-z, 0-9, Unicode
    > 161-255, hyphens, or escaped Unicode characters as numeric codes."




    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"


    --
    Luigi Donatello Asero
    https://www.scaiecat-spa-gigi.com/sv/faktaomitalien.php
    今天二零零六年二月二åå…­æ—¥
    星期日
    Luigi Donatello Asero, Feb 26, 2006
    #18
  19. Luigi Donatello Asero

    Els Guest

    David Dorward wrote:

    > Els wrote:
    >
    >> Then just use #sverige. There is only one element with id 'sverige' on
    >> the page (I hope!), so the class need not be mentioned.

    >
    > The same stylesheet might be used with multiple documents with an element of
    > id "sverige" but different pages could have different classes assigned to
    > that element.


    Yes - I actually thought of that before I wrote my reply, but I didn't
    want to complicate the matter further than necessary. That is, because
    I was under the impression that .foo#bar wasn't an allowed
    combination.

    Apparently, according to this link:
    http://penguin.theopalgroup.com/cgi-bin/css3explainer/selectoracle.py
    you can actually write it exactly as Luigi described.

    I didn't know that though - is it correct according to the W3C spec?

    --
    Els http://locusmeus.com/
    Els, Feb 26, 2006
    #19
  20. On 26/02/2006 01:11, Els wrote:

    > Luigi Donatello Asero wrote:
    >
    >> 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]. A 'simple' selector is an optional element name
    (including the universal element selector, '*'), followed by any number
    of attributes (including none, unless the element name is omitted), with
    no intervening whitespace.

    .subsubsection#sverige a

    would match an anchor (A element) that is a descendant of any element
    that has both a class attribute containing the word 'subsubsection' and
    an id attribute value that equals 'sverige'.

    This particular pattern might not be that useful - the id attribute
    selector would normally suffice on its own - but it's possible that
    though there may be many elements within the documents of a site with a
    given id attribute value, only a subset will also have the required
    class name, too.


    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.

    Mike


    [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>

    --
    Michael Winter
    Prefix subject with [News] before replying by e-mail.
    Michael Winter, Feb 26, 2006
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    4
    Views:
    699
    clintonG
    Dec 24, 2004
  2. E11
    Replies:
    1
    Views:
    4,716
    Thomas Weidenfeller
    Oct 12, 2005
  3. christopher diggins
    Replies:
    16
    Views:
    735
    Pete Becker
    May 4, 2005
  4. Joseph Turian
    Replies:
    5
    Views:
    578
  5. Ciaran
    Replies:
    9
    Views:
    488
    dorayme
    Mar 23, 2007
Loading...

Share This Page