Class attribute values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patient Guy

    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="thumbedI mage 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?


  • Spartanicus

    #2
    Re: Class attribute values

    Patient Guy <Patient.Guy@no where.to.be.fou nd.com> wrote:
    [color=blue]
    >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="thumbedI mage 0.4"
    >
    >is permitted,[/color]

    The above assigns two classes to the element, "thumbedIma ge" 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

    Comment

    • Stephen Poley

      #3
      Re: Class attribute values

      On Mon, 07 Nov 2005 07:27:04 GMT, Patient Guy
      <Patient.Guy@no where.to.be.fou nd.com> wrote:
      [color=blue]
      >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="thumbedI mage 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.[/color]
      ....[color=blue]
      >Is there anyone whose understanding of the specification differs from this
      >understandin g?[/color]


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

      class="thumbedI mage 0.4" assigns the classes "thumbedIma ge" 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: "identifier s (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


      Comment

      • Toby Inkster

        #4
        Re: Class attribute values

        Spartanicus wrote:
        [color=blue]
        > The above assigns two classes to the element, "thumbedIma ge" 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[/color]

        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

        Comment

        • Spartanicus

          #5
          Re: Class attribute values

          Toby Inkster <usenet200511@t obyinkster.co.u k> wrote:
          [color=blue][color=green]
          >> The above assigns two classes to the element, "thumbedIma ge" 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[/color]
          >
          >In HTML, class names *are* allowed to start with a digit.[/color]

          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

          Comment

          • David Dorward

            #6
            Re: Class attribute values

            Spartanicus wrote:
            [color=blue]
            > You're almost clever. Had you been really clever you might have noticed
            > that I didn't mention HTML and referenced the CSS rules.[/color]

            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

            Comment

            • Toby Inkster

              #7
              Re: Class attribute values

              Spartanicus wrote:
              [color=blue]
              > You're almost clever. Had you been really clever you might have noticed
              > that I didn't mention HTML and referenced the CSS rules.[/color]

              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

              Comment

              • Jan Roland Eriksson

                #8
                Re: Class attribute values

                On Mon, 07 Nov 2005 22:36:02 GMT, Spartanicus <invalid@invali d.invalid>
                wrote:
                [color=blue]
                >Toby Inkster <usenet200511@t obyinkster.co.u k> wrote:[color=green][color=darkred]
                >>> The above assigns two classes to the element, "thumbedIma ge" 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[/color][/color][/color]
                [color=blue][color=green]
                >>In HTML, class names *are* allowed to start with a digit.[/color][/color]
                [color=blue]
                >You're almost clever. Had you been really clever you might have noticed
                >that I didn't mention HTML and referenced the CSS rules.[/color]

                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


                Comment

                • Spartanicus

                  #9
                  Re: Class attribute values

                  Toby Inkster <usenet200511@t obyinkster.co.u k> wrote:
                  [color=blue][color=green]
                  >> You're almost clever. Had you been really clever you might have noticed
                  >> that I didn't mention HTML and referenced the CSS rules.[/color]
                  >
                  >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.[/color]

                  So it did, apologies for my remark.

                  --
                  Spartanicus

                  Comment

                  • Spartanicus

                    #10
                    Re: Class attribute values

                    David Dorward <dorward@yahoo. com> wrote:
                    [color=blue][color=green]
                    >> You're almost clever. Had you been really clever you might have noticed
                    >> that I didn't mention HTML and referenced the CSS rules.[/color]
                    >
                    >And had you been really clever you might have noticed that this is
                    >ciwa.*html*[/color]

                    And alt.html (where it shows up here). Btw, I undid your attempt to
                    remove alt.html from this thread.
                    [color=blue]
                    >, that the context of the question was HTML and JavaScript,[/color]

                    That I indeed missed.
                    [color=blue]
                    >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.[/color]

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

                    --
                    Spartanicus

                    Comment

                    • Neredbojias

                      #11
                      Re: Class attribute values

                      With neither quill nor qualm, Jan Roland Eriksson quothed:
                      [color=blue]
                      > On Mon, 07 Nov 2005 22:36:02 GMT, Spartanicus <invalid@invali d.invalid>
                      > wrote:
                      >[color=green]
                      > >Toby Inkster <usenet200511@t obyinkster.co.u k> wrote:[color=darkred]
                      > >>> The above assigns two classes to the element, "thumbedIma ge" 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[/color][/color]
                      >[color=green][color=darkred]
                      > >>In HTML, class names *are* allowed to start with a digit.[/color][/color]
                      >[color=green]
                      > >You're almost clever. Had you been really clever you might have noticed
                      > >that I didn't mention HTML and referenced the CSS rules.[/color]
                      >
                      > 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.[/color]

                      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.

                      Comment

                      • Neredbojias

                        #12
                        Re: Class attribute values

                        With neither quill nor qualm, Spartanicus quothed:

                        ....[color=blue]
                        > That doesn't change the fact that class names cannot start with a digit
                        > according to the CSS syntax rules.[/color]

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

                        --
                        Neredbojias
                        Contrary to popular belief, it is believable.

                        Comment

                        • Blinky the Shark

                          #13
                          Re: Class attribute values

                          Neredbojias wrote:
                          [color=blue]
                          > With neither quill nor qualm, Jan Roland Eriksson quothed:[/color]
                          [color=blue][color=green]
                          >> 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.[/color]
                          >
                          > Hah, what do you know? "Dumb ass hats" don't come in white.
                          > However, "dunce caps" may be procured in a light eggshell.[/color]

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


                          s/acaw.jpg


                          --
                          Blinky
                          Killing all Google Groups posts.

                          Comment

                          • Lachlan Hunt

                            #14
                            Re: Class attribute values

                            Toby Inkster wrote:[color=blue]
                            > Spartanicus wrote:
                            >[color=green]
                            >> The above assigns two classes to the element, "thumbedIma ge" 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[/color]
                            >
                            > 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...[/color]

                            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://GetFirefox.com/ Rediscover the Web
                            http://GetThunderbird.com/ Reclaim your Inbox

                            Comment

                            Working...