tag attributes,

Discussion in 'HTML' started by adam buxton, Oct 16, 2004.

  1. adam buxton

    adam buxton Guest

    hi all,
    i'm studying in england ona web design course and the assignment i've
    been set states i must use html 4.0 strict.

    i've found all the tags and attribute san dam ok with this i just have
    one question that the lecturer will not answer becouse it's also part
    of the assignment :s

    CLASS and ID are common attributes for every tag yes or no? and if yes
    is it then ok to give every tag an ID and a CLASS?

    the assignment stipulates the use of an averae of two attributes per
    tag?

    thanks in advance
     
    adam buxton, Oct 16, 2004
    #1
    1. Advertising

  2. adam buxton

    brucie Guest

    In alt.html adam buxton said:

    > CLASS and ID are common attributes for every tag yes or no?


    no


    --


    v o i c e s
     
    brucie, Oct 16, 2004
    #2
    1. Advertising

  3. adam buxton

    Nico Schuyt Guest

    Nico Schuyt, Oct 16, 2004
    #3
  4. adam buxton

    Kris Guest

    In article <yspkba5f1rto$>,
    brucie <> wrote:

    > > CLASS and ID are common attributes for every tag yes or no?

    >
    > no


    To clarify to the OP: they are common attributes for _nearly every
    element_. As far as I remember it comes down to the HTML and HEAD
    element and all those elements inside the head section that should not
    carry classes and IDs. You may want to double check that before
    restating it as a fact.

    Be sure to know the difference between tags and elements when digging in.

    --
    Kris
    <> (nl)
     
    Kris, Oct 16, 2004
    #4
  5. adam buxton

    brucie Guest

    In alt.html Kris said:

    >>> CLASS and ID are common attributes for every tag yes or no?


    >> no


    > To clarify to the OP: they are common attributes for _nearly every
    > element_. As far as I remember it comes down to the HTML and HEAD
    > element and all those elements inside the head section that should not
    > carry classes and IDs.


    to clarify for the OP: no

    > You may want to double check that before restating it as a fact.


    yes, that would be a good idea.

    you can check for yourself in 2 seconds here:
    http://www.w3.org/TR/html401/index/attributes.html

    --


    v o i c e s
     
    brucie, Oct 16, 2004
    #5
  6. adam buxton

    Kris Guest

    In article <>,
    brucie <> wrote:

    > >>> CLASS and ID are common attributes for every tag yes or no?

    >
    > > To clarify to the OP: they are common attributes for _nearly every
    > > element_. As far as I remember it comes down to the HTML and HEAD
    > > element and all those elements inside the head section that should not
    > > carry classes and IDs.

    >
    > to clarify for the OP: no


    I remembered wrongly. Nevertheless I was right on the 'nearly every
    element' bit.

    Good I had the disclaimer ready. :)

    > > You may want to double check that before restating it as a fact.

    >
    > yes, that would be a good idea.
    >
    > you can check for yourself in 2 seconds here:
    > http://www.w3.org/TR/html401/index/attributes.html


    Thanks for this. I learned something today...

    --
    Kris
    <> (nl)
     
    Kris, Oct 16, 2004
    #6
  7. adam buxton

    Andy Dingley Guest

    On 16 Oct 2004 04:03:51 -0700, (adam
    buxton) wrote:

    Ignore W3 Schools. If you're asking questions at this level, you need
    to read the real specification.
    http://www.w3.org/TR/html4/sgml/dtd.html

    Learn how to read a DTD. The effort will repay itself.

    >CLASS and ID are common attributes for every tag yes or no?


    They're certainly common, but not on _every_ element.

    Strictly speaking, they're "coreattrs". Inside the DTD an entity is
    declared called "coreattrs", which contains the set of attributes (
    id, class, style, title ). These are intended for "common" use across
    all elements (or nearly all). The element definitions then include
    this entity "coreattrs", or else the entity "attrs" (which includes
    coreattrs indirectly).

    AFAIK all the HTML elements include this entity, from <body> down.
    The elements used outside the body; <html>, <head>, <title> etc. are
    the ones that don't include them.

    Also "id" is an attribute, rather than "ID". Although HTML is
    case-insensitive, XML and XHTML are case-sensitive, and you should
    start paying attention to this.

    "ID" is a basic SGML type within the DTD. It has constrained
    behaviour; it must have a suitable format for a "name" and it must be
    unique in the document. Because id is declared as being an ID, it
    also behaves in this way. If you invent your own DTD though (maybe
    for some new XML application), attributes called "id" aren't unique
    identifiers unless you've also set their type.


    > if yes is it then ok to give every tag an ID and a CLASS?


    Yes (except for that handful of elements)


    >the assignment stipulates the use of an averae of two attributes per
    >tag?


    That's a crude rule of thumb, but it's a reminder to use plenty of
    these attributes, wherever they're appropriate. You can apply the
    same logic to the "title" attribute too.

    Searching this newsgroup for "semantic" will show you many threads on
    appropriate use of class and id.

    In general, I use lots of class attributes for the purposes of CSS and
    I use a few id attributes to assist with DHTML (client-side
    JavaScript). I use very few id attributes for CSS purposes.

    If there's the remotest likelihood that there could be more than one
    element of a particular style on the page, then use class rather than
    id. Even if you can't think why, just if it's not demonstrably wrong
    to have more than one. In DHTML though, it's often necessary to
    _uniquely_ identify an element, even if there are several very similar
    ones.

    Paste some of your code up for critique, if you want.

    --
    Smert' spamionam
     
    Andy Dingley, Oct 16, 2004
    #7
  8. adam buxton

    Nico Schuyt Guest

    Nico Schuyt, Oct 16, 2004
    #8
  9. adam buxton

    Andy Dingley Guest

    On Sat, 16 Oct 2004 16:00:31 +0200, "Nico Schuyt"
    <> wrote:

    >> http://www.w3.org/TR/html4/sgml/dtd.html

    >
    >At his level it's not likely he understands a word of that :)


    Probably not. But then maybe he'll post again asking for help.

    DTDs aren't _hard_, they're just seen as hard, really _are_ hard to
    locate an explanation for, then they get ignored.

    On a course that sems to be taking a reasonable approach to web
    design, then one would hope that the tutor would explain the
    significance and reading of a DTD.


    Anyone have a favourite link on the reading of DTDs ?
     
    Andy Dingley, Oct 16, 2004
    #9
  10. On Sat, 16 Oct 2004 16:52:54 +0100, Andy Dingley <>
    wrote:

    [snip]

    > Anyone have a favourite link on the reading of DTDs ?


    The basic explanation
    (<URL:http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.3>) earlier in the
    Recommendation was enough for me when I first started trying to read the
    DTDs. I don't know what anyone else thinks of it though.

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
     
    Michael Winter, Oct 16, 2004
    #10
    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. shruds
    Replies:
    1
    Views:
    837
    John C. Bollinger
    Jan 27, 2006
  2. Max
    Replies:
    1
    Views:
    484
    Joe Kesselman
    Sep 22, 2006
  3. P4trykx
    Replies:
    2
    Views:
    1,827
    bruce barker
    Jan 31, 2007
  4. james_027

    class attributes & data attributes

    james_027, Jun 20, 2007, in forum: Python
    Replies:
    2
    Views:
    377
    Bruno Desthuilliers
    Jun 20, 2007
  5. Kyle Schmitt
    Replies:
    3
    Views:
    194
    Kyle Schmitt
    Jul 24, 2007
Loading...

Share This Page