Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > When to use ID?

Reply
Thread Tools

When to use ID?

 
 
Chaddy2222
Guest
Posts: n/a
 
      11-30-2008
On Nov 30, 7:31*am, Neredbojias <(E-Mail Removed)> wrote:
> On 29 Nov 2008, shapper <(E-Mail Removed)> wrote:
>
> > Yes, the web site I work on fully validates HTML and CSS. I always
> > check my code ...

>
> > The reason of this post was more knowing if when an id is redundant if
> > people put it anyway or if only add id's when needed for selectors or
> > javascript.

>
> > I needed a second opinion because I was getting a lot of redundant
> > id's and because of it I needed to have many long CSS styles names ...

>
> > Thanks,
> > Miguel

>
> Putting ids on _all_ tags would be overkill. *I believe Jukka's point that
> putting them on important tags to assist users who choose to employ user
> style sheets might be perinent but then you have to decide which tags are
> important and which are not. *The vast majority of pagemakers assign ids
> only when they need to.
>

I agree with this, the way I do it is to have an ID for the main parts
of the page, the header, navigation etc. Then I just use other classes
and ID's where needed. The OP in his / her code example could just
style the IDs, the extra classes would be redundent.
--
Regards Chad. http://freewebdesignonline.org
 
Reply With Quote
 
 
 
 
Neredbojias
Guest
Posts: n/a
 
      12-01-2008
On 29 Nov 2008, Chaddy2222 <(E-Mail Removed)>
wrote:

>> > I needed a second opinion because I was getting a lot of redundant
>> > id's and because of it I needed to have many long CSS styles names
>> > ...

>> Putting ids on _all_ tags would be overkill. *I believe Jukka's
>> point t

> hat
>> putting them on important tags to assist users who choose to employ
>> user style sheets might be perinent but then you have to decide
>> which tags are important and which are not. *The vast majority of
>> pagemakers assign id

> s
>> only when they need to.
>>

> I agree with this, the way I do it is to have an ID for the main
> parts of the page, the header, navigation etc. Then I just use other
> classes and ID's where needed. The OP in his / her code example could
> just style the IDs, the extra classes would be redundent.


Exactly. Besides the points already mentioned, a trimmer page
undoubtedly works more expediently and there is less of a chance for
screwing something up. Wouldn't it frost you to make a, say, css
mistake in page coding you didn't really need to begin with?

--
Neredbojias
http://www.neredbojias.org/
http://www.neredbojias.net/
 
Reply With Quote
 
 
 
 
richard
Guest
Posts: n/a
 
      12-01-2008
On Fri, 28 Nov 2008 10:34:28 -0800 (PST), shapper <(E-Mail Removed)>
wrote:

>Hello,
>
>I always give an id to all my form elements ...
>
>But what about div's?
>
>When should I give an ID to a div?
>I have many div's with a CSS class but no id ... Is there a problem
>about it?
>
>Thanks,.
>Miguel



What's an ID? I rarely use one.

 
Reply With Quote
 
Awful Dog Autry
Guest
Posts: n/a
 
      12-01-2008
On 01 Dec 2008, richard <(E-Mail Removed)> wrote:

> On Fri, 28 Nov 2008 10:34:28 -0800 (PST), shapper <(E-Mail Removed)>
> wrote:
>
>>Hello,
>>
>>I always give an id to all my form elements ...
>>
>>But what about div's?
>>
>>When should I give an ID to a div?
>>I have many div's with a CSS class but no id ... Is there a problem
>>about it?
>>
>>Thanks,.
>>Miguel

>
>
> What's an ID? I rarely use one.
>
>


It must mean brain.

--
Awful Dog Autry
 
Reply With Quote
 
Bergamot
Guest
Posts: n/a
 
      12-01-2008

Awful Dog Autry wrote:
> On 01 Dec 2008, richard <(E-Mail Removed)> wrote:
>
>> What's an ID? I rarely use one.

>
> It must mean brain.


LOL

--
Berg
 
Reply With Quote
 
dorayme
Guest
Posts: n/a
 
      12-01-2008
In article <(E-Mail Removed)>,
richard <(E-Mail Removed)> wrote:

> On Fri, 28 Nov 2008 10:34:28 -0800 (PST), shapper <(E-Mail Removed)>
> wrote:
>
> >Hello,
> >
> >I always give an id to all my form elements ...
> >
> >But what about div's?
> >
> >When should I give an ID to a div?
> >I have many div's with a CSS class but no id ... Is there a problem
> >about it?
> >
> >Thanks,.
> >Miguel

>
>
> What's an ID? I rarely use one.


It's your truck driver's license. Don't tell me you drive without it
sometimes?

--
dorayme
 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      12-02-2008
On 28 Nov, 18:34, shapper <(E-Mail Removed)> wrote:

> When should I give an ID to a div?
> I have many div's with a CSS class but no id ... Is there a problem
> about it?


Use an id if you're planning to try and find it from JavaScript.

For CSS work, use class in preference.

You don't _need_ either, unless you know that you need them, or you
think you might need them pretty soon (if you're writing HTML first,
then trying to style it). It's certainly not a mistake or error to not
have them.
 
Reply With Quote
 
Adrienne Boswell
Guest
Posts: n/a
 
      12-02-2008
Gazing into my crystal ball I observed Andy Dingley
<(E-Mail Removed)> writing in news:8228853a-5253-4c9c-a982-
http://www.velocityreviews.com/forums/(E-Mail Removed):

> On 28 Nov, 18:34, shapper <(E-Mail Removed)> wrote:
>
>> When should I give an ID to a div?
>> I have many div's with a CSS class but no id ... Is there a problem
>> about it?

>
> Use an id if you're planning to try and find it from JavaScript.


Or if you want to give the ability to link to a fragment - eg.
mypets.html#cats - <h2 id="cats">Cats</h2>

>
> For CSS work, use class in preference.


I don't know about that. I style elements, and use ID for certain
parts, eg. #content, #nav, #header, #footer, all the "structural" parts
of a document, and then I use classes to apply "attributes" to those
ids.

>
> You don't _need_ either, unless you know that you need them, or you
> think you might need them pretty soon (if you're writing HTML first,
> then trying to style it). It's certainly not a mistake or error to not
> have them.
>


Agreed.

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Could not use ''; file already in use. M K ASP .Net 11 04-09-2008 11:35 AM
where to use CPLD & where to use FPGA? kulkarku@math.net VHDL 6 03-06-2006 07:27 AM
How do I know when to use the Viewstate and when to use the posted data? :-) Simon ASP .Net 1 11-09-2004 02:32 AM
Can I use XPath or something to a remote Mac or Linux box and just query an xml file, not using web services and use encyrption? jake ASP .Net 0 07-06-2004 02:16 PM
Cannot use the profile "default" because it is in use, not. please.post@yur.re.ply Firefox 1 07-04-2004 03:41 AM



Advertisments