frustrating id tags (1 Viewer)

rourkey

Registered User.
Local time
Yesterday, 20:58
Joined
Oct 24, 2006
Messages
14
Hi everyone (i'm new by the way)
i've got a small problem
the geezer who learnt me to design websites always told me to stay a country mile away from id tags he just says there bad news without really going further.
But when i go and visit other peoples source code and the inspect their css pages i come across these id tags and they seem to be the nuts and bolts of the css page!
i can get by designing a fairly decent site just using div classes but could some one point me in the right direction about id tags and * html that accompany them
 

Mile-O

Back once again...
Local time
Today, 04:58
Joined
Dec 10, 2002
Messages
11,316
rourkey said:
the geezer who learnt me to design websites always told me to stay a country mile away from id tags he just says there bad news without really going further.
He's just crap and doesn't know what he's talking about. Retrain.


But when i go and visit other peoples source code and the inspect their css pages i come across these id tags and they seem to be the nuts and bolts of the css page!

You are right. id and class tags are the bread and butter of CSS. You would use id for formatting items which will appear on the page once. You would use the class tag for items appearing multiple times.

So, for a quick page:

Code:
<html>
<head>
<title>Example</title>
<style>
.outer {
  border: 1px solid black;
}
#textpart {
  border: 5px dotted red;
  margin-left: 10px;
  padding: 10px;
}
</style>
</head>
<body>
<div id="outer">
<div class="textpart">
<p>Here is some text within the first box.</p>
</div>
<div class="textpart">
<p>Here is some text within the first box.</p>
</div>
</div>
</body>
</html>

An id tag is represented by a . in the CSS, and a class is represented by a #.

Try www.w3schools.com for more information on (X)HTML and CSS.
 

rourkey

Registered User.
Local time
Yesterday, 20:58
Joined
Oct 24, 2006
Messages
14
thanks,
i'm over the moon with w3schools and the tutorials
 

RickDB

Registered User.
Local time
Yesterday, 23:58
Joined
Jun 29, 2006
Messages
101
The functional difference between class & id tags has always been the difference between id are used once per page, class used many times. But as far as I know that is technically incorrect, there is nothing to stop you from using id tags on a page repeatedly, though I have not tried, so I am not an authority on the subject.

Besides following semantic guidelines (in almost all cases a wise thing to do, though I would debate a few principles of semantics at this early point in it being adopted), the main benefit from the ID tag is incorporating it into Javasript, and its inherent organizational benefits as well.

You will find many people give advice to drop use of certain elements, but others who are advocates for the same thing.

One example: the Title tag is often not used by many sites (the text that display when a mouse pointer hovers over a picture / element), but is used heavily on others. The Alt tag serves the same function as far as hover goes, but the Title tag can be used for custom Javascript applications also (I suppose Alt could be too, but you can use Title specifically for this and still use Alt for its intended purpose).
 

Users who are viewing this thread

Top Bottom