Tutorials-Good Code vs How Too

Discussion in 'HTML' started by Uglysocks, Oct 19, 2003.

  1. Uglysocks

    Uglysocks Guest

    I am trying to learn CSS. I've worked through a couple of tutorials that
    explain how-to, but don't specify good programming standards. I've
    recently put up a site that is based on a Strange Banana (
    http://www.strangebanana.com/generator.aspx ) example. The CSS generated
    by Strange Banana wants to rely on id's, but it seems to me that classes
    would be better style. Are there any tutorials that emphasize good, clean
    CSS for more easily maintainable sites.

    Thanks
    --
    tm
     
    Uglysocks, Oct 19, 2003
    #1
    1. Advertising

  2. Uglysocks wrote:
    > The CSS generated
    > by Strange Banana wants to rely on id's, but it seems to me that classes
    > would be better style.


    No they wouldn't. The only case where classes would be better than IDs
    is someone using the same ID multiple times, or to specify multiple
    elements of the same type (#foo1, #foo2, and #foo3 with the same style).
     
    Leif K-Brooks, Oct 19, 2003
    #2
    1. Advertising

  3. Leif K-Brooks wrote:
    > Uglysocks wrote:
    >> The CSS generated
    >> by Strange Banana wants to rely on id's, but it seems to me that
    >> classes would be better style.

    >
    > No they wouldn't. The only case where classes would be better than IDs
    > is someone using the same ID multiple times, or to specify multiple
    > elements of the same type (#foo1, #foo2, and #foo3 with the same
    > style).


    Is the necessity for multiple use on the same page the ONLY criterion for
    using CLASS rather than ID? If they function the same way, why not alway
    use CLASS? I'm totally confused on this point...
     
    nj_dilettante, Oct 19, 2003
    #3
  4. nj_dilettante wrote:

    > Is the necessity for multiple use on the same page the ONLY criterion for
    > using CLASS rather than ID? If they function the same way, why not alway
    > use CLASS? I'm totally confused on this point...


    Because ID can be used to identify elements for things besides style sheets.
     
    Leif K-Brooks, Oct 19, 2003
    #4
  5. Leif K-Brooks wrote:
    > nj_dilettante wrote:
    >
    >> Is the necessity for multiple use on the same page the ONLY
    >> criterion for using CLASS rather than ID? If they function the same
    >> way, why not alway use CLASS? I'm totally confused on this point...

    >
    > Because ID can be used to identify elements for things besides style
    > sheets.


    Unfortunately for me, I'm still confused. The examples I've seen in this NG
    usually show the use of ID and CLASS in what seem to me to be
    interchangeable situations. Can you give me an example where the ID tag
    MUST be used in CSS?
     
    nj_dilettante, Oct 19, 2003
    #5
  6. nj_dilettante wrote:

    > Unfortunately for me, I'm still confused. The examples I've seen in this NG
    > usually show the use of ID and CLASS in what seem to me to be
    > interchangeable situations. Can you give me an example where the ID tag
    > MUST be used in CSS?


    There are none, but it's an attribute not a tag.
     
    Leif K-Brooks, Oct 19, 2003
    #6
  7. Uglysocks

    brucie Guest

    In post <6jpkb.184228$>
    nj_dilettante said...

    > Unfortunately for me, I'm still confused. The examples I've seen in this NG
    > usually show the use of ID and CLASS in what seem to me to be
    > interchangeable situations. Can you give me an example where the ID tag
    > MUST be used in CSS?


    <quote>
    The id attribute has several roles in HTML:
    * As a style sheet selector.
    * As a target anchor for hypertext links.
    * As a means to reference a particular element from a script.
    * As the name of a declared OBJECT element.
    * For general purpose processing by user agents (e.g. for identifying
    fields when extracting data from HTML pages into a database,
    translating HTML documents into other formats, etc.).

    The class attribute, on the other hand, assigns one or more class
    names to an element; the element may be said to belong to these
    classes. A class name may be shared by several element instances. The
    class attribute has several roles in HTML:
    * As a style sheet selector (when an author wishes to assign style
    information to a set of elements).
    * For general purpose processing by user agents.

    </quote>
    7.5.2 Element identifiers: the id and class attributes
    http://www.w3.org/TR/html401/struct/global.html#h-7.5.2


    --
    brucie.
    19/October/2003 05:05:53 pm
     
    brucie, Oct 19, 2003
    #7
  8. Uglysocks

    Kris Guest

    In article
    <6jpkb.184228$>,
    "nj_dilettante" <> wrote:

    > Unfortunately for me, I'm still confused. The examples I've seen in this NG
    > usually show the use of ID and CLASS in what seem to me to be
    > interchangeable situations. Can you give me an example where the ID tag
    > MUST be used in CSS?


    If you play Warcraft III:
    The ID attribute is a Hero, the CLASS attribute a foot soldier.

    --
    Kris
    erlands (nl)
     
    Kris, Oct 19, 2003
    #8
  9. Uglysocks

    Sid Ismail Guest

    Sid Ismail, Oct 19, 2003
    #9
    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. Chaos Master

    Good books/tutorials on VHDL?

    Chaos Master, Feb 18, 2004, in forum: VHDL
    Replies:
    1
    Views:
    622
  2. Eric DELAGE
    Replies:
    2
    Views:
    753
  3. sd
    Replies:
    4
    Views:
    3,110
  4. Thomas S.
    Replies:
    0
    Views:
    614
    Thomas S.
    Nov 12, 2004
  5. Collin VanDyck

    Good Tutorials?

    Collin VanDyck, Dec 8, 2004, in forum: Java
    Replies:
    1
    Views:
    390
Loading...

Share This Page