Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts

    is it possible (and 'legal') to define two classes

    to the same objhect?

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    you can have both ID and class but not multiple of either AFAIK

  • #3
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    You can use multiple, space delimited classes, though support is likely to be limited to more recent browser version.

    e.g.
    Code:
    class="class1 class2 class3"
    [edit]

    Support info…

    http://www.pixelsurge.com/experiment/multiplestyles.htm
    http://www.quirksmode.org/index.html...leclasses.html

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Bill Posters
    You can use multiple, space delimited classes, though support is likely to be limited to more recent browser version.

    e.g.
    Code:
    class="class1 class2 class3"
    [edit]

    Support info…

    http://www.pixelsurge.com/experiment/multiplestyles.htm
    http://www.quirksmode.org/index.html...leclasses.html
    it works, but is it valid?

  • #5
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by ShMiL
    it works, but is it valid?
    I wouldn't suggest it if it wasn't.

    Quote Originally Posted by W3C
    7.5.2 Element identifiers: the id and class attributes

    Attribute definitions



    This attribute assigns a class name or set of class names to an element. Any number of elements may be assigned the same class name or names. Multiple class names must be separated by white space characters.
    http://www.w3.org/TR/REC-html40/stru...l.html#h-7.5.2

    If in doubt, you could try running a page which uses multiple class values through the validator.
    Last edited by Bill Posters; 12-09-2005 at 02:33 PM.

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    this confused me a bit, but after I read it again, i got it...

    Note: Only one class attribute can be specified per HTML element! The example

    http://www.w3schools.com/css/css_syntax.asp

    thanks

  • #7
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,640
    Thanks
    0
    Thanked 649 Times in 639 Posts
    You are only allowed one class attribute but that attribute can contain multiple space separated class names.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall
    You are only allowed one class attribute but that attribute can contain multiple space separated class names.
    yeah, I got it


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •