tag attributes,

A

adam buxton

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
 
K

Kris

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

no[/QUOTE]

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.
 
B

brucie

In alt.html Kris said:
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
 
K

Kris

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[/QUOTE]

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

Good I had the disclaimer ready. :)
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...
 
A

Andy Dingley

On 16 Oct 2004 04:03:51 -0700, (e-mail address removed) (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.
 
A

Andy Dingley

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 ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,830
Latest member
HeleneMull

Latest Threads

Top