Multiple Classes in "class" ok?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Will Hartung

    Multiple Classes in "class" ok?

    Can someone clarify that multiple classes in the "class" attribute are ok
    and "legal" and not some fluke?

    So, I can do:

    ..pink {color: pink}
    ..bold {font-weight: bold}
    ..medium {font-size: 12pt}

    <p class="bold pink medium">bold pink medium sized text</p>

    You can use multiple classes, but not multiple id's, so id="this that other"
    is wrong.

    Most every example of classes only asserts one class.

    Thanx!

    Regards,

    Will Hartung
    (willh@msoft.co m)


  • Barbara de Zoete

    #2
    Re: Multiple Classes in &quot;class&quo t; ok?

    On Thu, 3 Feb 2005 10:47:18 -0800, Will Hartung <willh@msoft.co m> wrote:
    [color=blue]
    > Can someone clarify that multiple classes in the "class" attribute are ok
    > and "legal" and not some fluke?
    >[/color]

    They are 'legal', yes, as gets explained in this group about fifty times a year
    :-(
    [color=blue]
    > So, I can do:
    >
    > .pink {color: pink}
    > .bold {font-weight: bold}
    > .medium {font-size: 12pt}
    >[/color]

    No, you can't. Again, as gets explained in this group about fifty times a year,
    using pt as unit for font-size is a bad idea. Google for the reason.
    [color=blue]
    > <p class="bold pink medium">bold pink medium sized text</p>
    >[/color]

    Well, this could be okay. I do not like your choice of selectors, class names
    though. Use something semantic so you remember why you put a class with an
    element. And be very careful with names that are attributes, properties, values,
    what ever. Confusion is close by if you do that.
    [color=blue]
    > You can use multiple classes, but not multiple id's, so id="this that other"
    > is wrong.
    >[/color]

    What would be the use? How would you refer to the element with a multiple id?
    You could however write id="this" class="that other".

    I'm actually not really sure if one can use multiple values for one id
    attribute. Maybe someone else. I don't want to go Google for it or dig down
    <http://www.w3.org/TR/html401/struct/global.html#ade f-id>. Maybe you can look
    there yourself.

    --
    ,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
    | weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
    | webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
    |zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
    `-------------------------------------------------- --<--@ ------------'

    Comment

    • Stanimir Stamenkov

      #3
      [OT] Re: Multiple Classes in &quot;class&quo t; ok?

      /Barbara de Zoete/:[color=blue]
      > On Thu, 3 Feb 2005 10:47:18 -0800, Will Hartung <willh@msoft.co m> wrote:
      >[color=green]
      >> Can someone clarify that multiple classes in the "class" attribute are ok
      >> and "legal" and not some fluke?[/color]
      >
      > They are 'legal', yes, as gets explained in this group about fifty times
      > a year :-([/color]

      It's a damn good number ("fifty per year"), I think. :-)

      --
      Stanimir

      Comment

      • Michael Winter

        #4
        Re: Multiple Classes in &quot;class&quo t; ok?

        Barbara de Zoete wrote:
        [color=blue]
        > On Thu, 3 Feb 2005 10:47:18 -0800, Will Hartung <willh@msoft.co m>
        > wrote:[/color]

        [snip]
        [color=blue][color=green]
        >> So, I can do:
        >>
        >> .pink {color: pink}
        >> .bold {font-weight: bold}
        >> .medium {font-size: 12pt}[/color]
        >
        > No, you can't.[/color]

        That's rather misleading on two levels. First, I initially assumed you
        were objecting to syntax, however there's nothing wrong in that
        respect. I think you could have phrased your objection better. Second,
        the OP *can* use pt units, but what one can do and what one *should*
        do can be very different things.
        [color=blue]
        > I'm actually not really sure if one can use multiple values for one
        > id attribute.[/color]

        It doesn't make any sense to do so. An id is a unique value so what
        could be gained by having more than one of them? Moreover, the ID data
        type doesn't permit spaces so a space-separated list wouldn't be possible.

        Mike

        --
        Michael Winter
        Replace ".invalid" with ".uk" to reply by e-mail.

        Comment

        • Spartanicus

          #5
          Re: Multiple Classes in &quot;class&quo t; ok?

          "Barbara de Zoete" <b_de_zoete@hot mail.com> wrote:
          [color=blue]
          >I'm actually not really sure if one can use multiple values for one id
          >attribute.[/color]

          Nope (and multiple id attributes is also not valid :)

          --
          Spartanicus

          Comment

          • Will Hartung

            #6
            Re: Multiple Classes in &quot;class&quo t; ok?


            "Michael Winter" <m.winter@bluey onder.co.invali d> wrote in message
            news:b3vMd.6505 $8B3.599@text.n ews.blueyonder. co.uk...[color=blue]
            > Barbara de Zoete wrote:
            >[color=green]
            > > On Thu, 3 Feb 2005 10:47:18 -0800, Will Hartung <willh@msoft.co m>
            > > wrote:[/color]
            >
            > [snip]
            >[color=green][color=darkred]
            > >> So, I can do:
            > >>
            > >> .pink {color: pink}
            > >> .bold {font-weight: bold}
            > >> .medium {font-size: 12pt}[/color]
            > >
            > > No, you can't.[/color]
            >
            > That's rather misleading on two levels. First, I initially assumed you
            > were objecting to syntax, however there's nothing wrong in that
            > respect. I think you could have phrased your objection better. Second,
            > the OP *can* use pt units, but what one can do and what one *should*
            > do can be very different things.[/color]

            Funny, I WAS going to put:

            ..medium {font-size: 12px}

            But I figured I would get screamed at, even though I was just curious about
            the syntax and contrived an example.

            Regards,

            Will Hartung
            (willh@msoft.co m)


            Comment

            • Mark Carroll

              #7
              Re: Multiple Classes in &quot;class&quo t; ok?

              In article <36f9tnF51t2ihU 1@individual.ne t>,
              Will Hartung <willh@msoft.co m> wrote:[color=blue]
              >Can someone clarify that multiple classes in the "class" attribute are ok
              >and "legal" and not some fluke?
              >
              >So, I can do:
              >
              >.pink {color: pink}
              >.bold {font-weight: bold}
              >.medium {font-size: 12pt}
              >
              ><p class="bold pink medium">bold pink medium sized text</p>[/color]
              (snip)

              Yes, that's fine - certainly it's in the CSS2.1 specification.
              Browser support may be another matter: ISTR there's at least one
              common browser that has problems with it, but I forget which.

              -- Mark

              Comment

              • Michael Winter

                #8
                Re: Multiple Classes in &quot;class&quo t; ok?

                Mark Carroll wrote:

                [snip]
                [color=blue]
                > ISTR there's at least one common browser that has problems with it,
                > but I forget which.[/color]

                Both NN4 and IE4 fail to respect multiple class names. No style is
                applied in that case. However, I wouldn't call either "common". I'm
                not sure if other user agents act similarly.

                Mike

                --
                Michael Winter
                Replace ".invalid" with ".uk" to reply by e-mail.

                Comment

                • Lauri Raittila

                  #9
                  Re: Multiple Classes in &quot;class&quo t; ok?

                  in comp.infosystem s.www.authoring.stylesheets, Mark Carroll wrote:[color=blue]
                  > In article <36f9tnF51t2ihU 1@individual.ne t>,
                  > Will Hartung <willh@msoft.co m> wrote:[color=green]
                  > >Can someone clarify that multiple classes in the "class" attribute are ok
                  > >and "legal" and not some fluke?
                  > >
                  > >So, I can do:
                  > >
                  > >.pink {color: pink}
                  > >.bold {font-weight: bold}
                  > >.medium {font-size: 12pt}
                  > >
                  > ><p class="bold pink medium">bold pink medium sized text</p>[/color]
                  > (snip)
                  >
                  > Yes, that's fine - certainly it's in the CSS2.1 specification.
                  > Browser support may be another matter: ISTR there's at least one
                  > common browser that has problems with it, but I forget which.[/color]

                  Not with that syntax, I believe, but things like .pink.bold {
                  color:yellow;fo nt-weigh:normal;} don't work as well.

                  --
                  Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
                  Utrecht, NL.

                  Comment

                  • Del Ferguson

                    #10
                    Re: Multiple Classes in &quot;class&quo t; ok?


                    "Mark Carroll" <markc@chiark.g reenend.org.uk> wrote in message
                    news:Scd*ihkGq@ news.chiark.gre enend.org.uk...[color=blue]
                    > In article <36f9tnF51t2ihU 1@individual.ne t>,
                    > Will Hartung <willh@msoft.co m> wrote:[color=green]
                    >>Can someone clarify that multiple classes in the "class" attribute are
                    >>ok
                    >>and "legal" and not some fluke?
                    >>
                    >>So, I can do:
                    >>
                    >>.pink {color: pink}
                    >>.bold {font-weight: bold}
                    >>.medium {font-size: 12pt}
                    >>
                    >><p class="bold pink medium">bold pink medium sized text</p>[/color]
                    > (snip)
                    >
                    > Yes, that's fine - certainly it's in the CSS2.1 specification.
                    > Browser support may be another matter: ISTR there's at least one
                    > common browser that has problems with it, but I forget which.
                    >
                    > -- Mark[/color]

                    Mark,

                    My "not-so-original" multiple classes ( class="navy small justify" )
                    seem to work fine with IE6 and Firefox. Doesn't that cover about 75% of
                    the World? Pages and CSS validate at W3C.

                    Del Ferguson



                    Comment

                    • saz

                      #11
                      Re: Multiple Classes in &quot;class&quo t; ok?

                      In article <opslmyffa1x5vg ts@zoete_b>, b_de_zoete@hotm ail.com says...[color=blue]
                      > On Thu, 3 Feb 2005 10:47:18 -0800, Will Hartung <willh@msoft.co m> wrote:
                      >[color=green]
                      > > Can someone clarify that multiple classes in the "class" attribute are ok
                      > > and "legal" and not some fluke?
                      > >[/color]
                      >
                      > They are 'legal', yes, as gets explained in this group about fifty times a year
                      > :-(
                      >[color=green]
                      > > So, I can do:
                      > >
                      > > .pink {color: pink}
                      > > .bold {font-weight: bold}
                      > > .medium {font-size: 12pt}
                      > >[/color]
                      >
                      > No, you can't. Again, as gets explained in this group about fifty times a year,
                      > using pt as unit for font-size is a bad idea. Google for the reason.[/color]

                      What are you talking about? Of course he can use pt as a unit if he
                      wants. It is "legal".
                      [color=blue][color=green]
                      > > <p class="bold pink medium">bold pink medium sized text</p>
                      > >[/color]
                      >
                      > Well, this could be okay.[/color]

                      Again, what are you talking about? Of course it is okay, he can name it
                      whatever he wants.

                      Comment

                      • Christoph Paeper

                        #12
                        Re: Multiple Classes in &quot;class&quo t; ok?

                        *Spartanicus* <me@privacy.net >:[color=blue]
                        >
                        > Nope (and multiple id attributes is also not valid :)[/color]

                        Not even multiple attributes of type ID.

                        --
                        Useless Facts #14:
                        There are 102,981,500 ways to combine six of the 8-studed LEGO bricks of one
                        color.
                        Since 1949, the LEGO company, based in Denmark, has produced more than
                        200,000,000,000 of the plastic elements that make up the Lego System.

                        Comment

                        • Christoph Paeper

                          #13
                          Re: Multiple Classes in &quot;class&quo t; ok?

                          *Del Ferguson* <ra19608081@cha rter.net>:[color=blue]
                          >
                          > My "not-so-original" multiple classes ( class="navy small justify" )
                          > seem to work fine with IE6 and Firefox.[/color]

                          The former doesn't have a problem with the HTML, but with CSS selectors
                          like ".navy.smal l".

                          --
                          No sig today, my .sig has gone away
                          The divider stands forlorn, a symbol of the dawn
                          No sig today, it seems a common sight
                          But people reading by don't know the reason why

                          Comment

                          • Barbara de Zoete

                            #14
                            Re: Multiple Classes in &quot;class&quo t; ok?

                            On Thu, 3 Feb 2005 15:11:44 -0600, saz <saz1958@nospam mersexcite.com> wrote:
                            [color=blue]
                            > In article <opslmyffa1x5vg ts@zoete_b>, b_de_zoete@hotm ail.com says...[color=green]
                            >> On Thu, 3 Feb 2005 10:47:18 -0800, Will Hartung <willh@msoft.co m> wrote:
                            >>[color=darkred]
                            >> > <p class="bold pink medium">bold pink medium sized text</p>
                            >> >[/color]
                            >>
                            >> Well, this could be okay.[/color]
                            >
                            > Again, what are you talking about? Of course it is okay, he can name it
                            > whatever he wants.[/color]

                            As you so conveniently snipped away, what followed was:
                            [color=blue][color=green]
                            >> I do not like your choice of selectors,
                            >> class names though.[/color][/color]

                            And then I explained why as well:
                            [color=blue][color=green]
                            >> Use something semantic so you remember why you put a class with
                            >> an element. And be very careful with names that are
                            >> attributes, properties, values, what ever. Confusion is close by
                            >> if you do that.[/color][/color]

                            Had nothing to do with 'legal' in this context, just with what would be the
                            wiser thing to do. Try maintaining a site that uses .green and .big as classes,
                            instead of meaningful class names. Try do a complete make over of the styles
                            with classes like .pink and .medium. Good luck with it.

                            --
                            ,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
                            | weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
                            | webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
                            |zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
                            `-------------------------------------------------- --<--@ ------------'

                            Comment

                            • Ali Babba

                              #15
                              Re: Multiple Classes in &quot;class&quo t; ok?

                              Barbara de Zoete wrote:
                              [color=blue]
                              > On Thu, 3 Feb 2005 15:11:44 -0600, saz <saz1958@nospam mersexcite.com>
                              > wrote:
                              >[color=green]
                              >> In article <opslmyffa1x5vg ts@zoete_b>, b_de_zoete@hotm ail.com says...
                              >>[color=darkred]
                              >>> On Thu, 3 Feb 2005 10:47:18 -0800, Will Hartung <willh@msoft.co m> wrote:
                              >>>
                              >>> > <p class="bold pink medium">bold pink medium sized text</p>
                              >>> >
                              >>>
                              >>> Well, this could be okay.[/color]
                              >>
                              >>
                              >> Again, what are you talking about? Of course it is okay, he can name it
                              >> whatever he wants.[/color]
                              >
                              >
                              > As you so conveniently snipped away, what followed was:
                              >[color=green][color=darkred]
                              > >> I do not like your choice of selectors,
                              > >> class names though.[/color][/color]
                              >
                              > And then I explained why as well:
                              >[color=green][color=darkred]
                              > >> Use something semantic so you remember why you put a class with
                              > >> an element. And be very careful with names that are
                              > >> attributes, properties, values, what ever. Confusion is close by
                              > >> if you do that.[/color][/color]
                              >
                              > Had nothing to do with 'legal' in this context, just with what would be
                              > the wiser thing to do. Try maintaining a site that uses .green and .big
                              > as classes, instead of meaningful class names. Try do a complete make
                              > over of the styles with classes like .pink and .medium. Good luck with it.
                              >[/color]

                              ..green, .big, .pink, .medium are not meaningful ?
                              the meaning of such classes appear pretty clear to me.

                              or should we instead use classnames like:
                              ..sinterklaas, .kerst, .oud-en-nieuw ???
                              does that automatically tell what the class is about ???

                              your point is very right, but your example is anything but justified.

                              Comment

                              Working...