Web Design Web Design Forum
Registration is free! Here you can view your subscribed threads, work with private messages and edit your profile and preferences Calendar Find other members Frequently Asked Questions Search
Home Web Design

Convenient web based access to our favorite web design Usenet groups

web design reviews

This is Interesting: Free Magazines for Graphics designers and webmasters  





Pages (2): [1] 2 »   Last Thread  Next Thread
Author
Thread Post New Thread   

basic descendant selector question
 

Laurence Tureaud




quote this post edit post

IP Loged report this post

Old Post  06-17-04 - 09:18 AM  
hello

i'm just getting started with CSS & am reading through Eric Meyer on
CSS, specifically the first chapter.

he creates these styles:

td#advert {stuff}
#content-top td { stuff }
tr td#sidetop {stuff }

so my questions....

1. can i shorten td#advert to just #advert?

2. can i shorten tr td#sidetop to just #sidetop?

tia -
Mr T.


Post Follow-Up to this message ]
Re: basic descendant selector question
 

Owen Jacobson




quote this post edit post

IP Loged report this post

Old Post  06-17-04 - 09:18 AM  
On Wed, 16 Jun 2004 19:11:51 -0700, Laurence Tureaud wrote:

> hello
>
>   i'm just getting started with CSS & am reading through Eric Meyer on
> CSS, specifically the first chapter.
>
> he creates these styles:
>
> td#advert {stuff}
> #content-top td { stuff }
> tr td#sidetop {stuff }
>
> so my questions....
>
> 1. can i shorten td#advert to just #advert?

Yes, but it's only recommended if either the holder of the 'advert' ID
will never change or all the styles are relevant to any possible 'advert'
element.  Keep in mind an ID may be used more than once on different pages.

> 2. can i shorten tr td#sidetop to just #sidetop?

Decide for yourself by working out which elements on which pages the
former and the latter select and then determining if the difference is
relevant.

--
Some say the Wired doesn't have political borders like the real world,
but there are far too many nonsense-spouting anarchists or idiots who
think that pranks are a revolution.



Post Follow-Up to this message ]
Re: basic descendant selector question
 

Brian




quote this post edit post

IP Loged report this post

Old Post  06-17-04 - 09:18 AM  
Laurence Tureaud wrote:

> td#advert {stuff}
> #content-top td { stuff }
> tr td#sidetop {stuff }
>
> 1. can i shorten td#advert to just #advert?

This depends on the context. td#advert selects only <td> elements
whose id="advert", while #advert selects any element whose
id="advert". Will another page have <div id="advert">? Do you want the
style to apply to both?

> 2. can i shorten tr td#sidetop to just #sidetop?

I'm not sure about the point of tr. A <td> element is *always* a
descendent of <tr>, so it seems superfluous. But beyond that, the same
question applies. What do you want to style? <td id="sidetop">? Or any
element whose id="sidetop"?

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/


Post Follow-Up to this message ]
Re: basic descendant selector question
 

Laurence Tureaud




quote this post edit post

IP Loged report this post

Old Post  06-17-04 - 09:18 AM  
On Thu, 17 Jun 2004 02:14:22 GMT, Owen Jacobson
<angstrom@lionsanctuary.net> wrote:
 
>
> Yes, but it's only recommended if either the holder of the 'advert' ID
> will never change or all the styles are relevant to any possible 'advert'
> element.  Keep in mind an ID may be used more than once on different
> pages.
aha..  but an ID should be used only once on any given page, right?
because a book i'm reading "dreamweaver 2004 mx missing manual" says an
ID is for formatting a unique item on a page.

I understand what you say about multiple pages though.

thanks-
matt


Post Follow-Up to this message ]
Re: basic descendant selector question
 

Harlan Messinger




quote this post edit post

IP Loged report this post

Old Post  06-17-04 - 09:18 AM  
pitythefool@XXXXXXXXXX (Laurence Tureaud) wrote:

>hello
>
>  i'm just getting started with CSS & am reading through Eric Meyer on
>CSS, specifically the first chapter.
>
>he creates these styles:
>
>td#advert {stuff}
>#content-top td { stuff }
>tr td#sidetop {stuff }
>
>so my questions....
>
>1. can i shorten td#advert to just #advert?

Yes, if the element with id="advert" on your pages is always a TD.

>
>2. can i shorten tr td#sidetop to just #sidetop?

Likewise. The tr seems especially pointless since you can't have a TD
that isn't inside a TR.

--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ๔ter le premier point de mon adresse de courriel.


Post Follow-Up to this message ]
Re: basic descendant selector question
 

Harlan Messinger




quote this post edit post

IP Loged report this post

Old Post  06-17-04 - 09:18 AM  
"Laurence Tureaud" <pitythefool@XXXXXXXXXX> wrote:

>On Thu, 17 Jun 2004 02:14:22 GMT, Owen Jacobson
><angstrom@lionsanctuary.net> wrote:
> 
>aha..  but an ID should be used only once on any given page, right?

Right.


--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ๔ter le premier point de mon adresse de courriel.


Post Follow-Up to this message ]
Re: basic descendant selector question
 

Laurence Tureaud




quote this post edit post

IP Loged report this post

Old Post  06-17-04 - 09:19 AM  
ok good.  i think i'm getting this stuff.

> This depends on the context. td#advert selects only <td> elements whose
> id="advert", while #advert selects any element whose id="advert". Will
> another page have <div id="advert">? Do you want the style to apply to
> both?
but wouldn't it be a bit sloppy to use the same id name in different
places?

are there any performance related issues with either approach?  i thought
maybe using a more specific path would speed the application of the style.

thanks again-
matt


Post Follow-Up to this message ]
Re: basic descendant selector question
 

Brian




quote this post edit post

IP Loged report this post

Old Post  06-17-04 - 09:19 AM  
Laurence Tureaud wrote:

> an ID should be used only once on any given page, right?

Yes. But it can be used on a different page on the same site, and both
pages could (and normally would) use the same stylesheet.

> a book i'm reading "dreamweaver 2004 mx missing manual" says an
> ID is for formatting a unique item on a page.

Well that definition seems rather limiting. The id attribute is meant
to be used as a fragment identifier for urls; it can also be used in
css selectors, in javascript, and probably for other things I cannot
think of. You might want to find something more reliable than a
Dreamweaver manual to explain www terminology.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/


Post Follow-Up to this message ]
Re: basic descendant selector question
 

Brian




quote this post edit post

IP Loged report this post

Old Post  06-17-04 - 09:19 AM  
Laurence Tureaud wrote:

> ok good.  i think i'm getting this stuff.
> 
>
> wouldn't it be a bit sloppy to use the same id name in different
> places?

No, not at all. It's nearly ubiquitous for every page of a site to
have a navigation section, and quite common for the container of said
navigation to have id="nav" or something similar, on every page of the
site.

> are there any performance related issues with either approach?  i thought
> maybe using a more specific path would speed the application of the style.

I know of no studies to suggest any difference in document rendering
by using id instead of, say, class or element selector.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/


Post Follow-Up to this message ]
Re: basic descendant selector question
 

Barry Pearson




quote this post edit post

IP Loged report this post

Old Post  06-17-04 - 12:15 PM  
Laurence Tureaud wrote:
> hello
>
>   i'm just getting started with CSS & am reading through Eric Meyer on
> CSS, specifically the first chapter.
>
> he creates these styles:
>
> td#advert {stuff}
> #content-top td { stuff }
> tr td#sidetop {stuff }
[snip]

You've received lots of good answers. But I wonder if there is something mor
e?
Have a look at these posts by Eric in response to queries like this elsewher
e.
(It is to do with maximising specificity in certain cases).

http://groups.google.com/groups?sel...di
a.com

http://groups.google.com/groups?sel...di
a.com

--
Barry Pearson
http://www.Barry.Pearson.name/photography/
http://www.BirdsAndAnimals.info/
http://www.ChildSupportAnalysis.co.uk/




Post Follow-Up to this message ]
Sponsored Links
 





All times are GMT. The time now is 04:00 AM. Post New Thread   
Pages (2): [1] 2 »   Previous Last Thread   Next Thread next
Stylesheets archive | Show Printable Version | Email this Page | Subscribe to this Thread

Popular forums

Adobe Photoshop forum Macromedia Flash Web Site Design
Dreamweaver FrontPage forum
JavaScript Forum XML forum
Style Sheets VRML
Forum Jump:
Rate This Thread:

 

XML RSS Feed web design latest articles Syndicate our forum via XML or simple JavaScript

Web Design archive  Database administration help  


Top Home  -  Register  -  Control Panel   -  Memberlist  -  Calendar  -  Faq  -  Search Top