Help - Search - Members - Calendar
Full Version: ID and Class in CSS
HTMLHelp Forums > Web Authoring > Cascading Style Sheets
uxk8396
Hi,
In what circumstances do we use a div Id and a div class in CSS?

Regards, sad.gif


Darin McGrew
Are there going to be more than one of them? If so, then you must use CLASS.

Is there going to be only one of them? If so, then you can use either.

Using ID is appropriate when the name identifies the element uniquely and clearly.
pandy
The usefulness of id lies in its high specificity.

'#foo p' will always override '.bar p', but '.foo p' will only override '.bar p' if it comes later in the cascade.
uxk8396
Hello,
Is there a way to use a property in CSS in order to center the navigation bar?
I cannot get it centered for some obvious reason.

How do you check if your codes are OK in Dreamweaver, just like in Flash we can check syntax for errors.

Thank you very much.
pandy
It depends on what you want to center. Inline elements or a block.
http://www.w3.org/Style/Examples/007/center.html

For CSS use w3c's checker.
http://jigsaw.w3.org/css-validator/
For HTML use the validator at this site or the w3c one.
http://htmlhelp.com/tools/validator/
http://validator.w3.org/

They can all do local files. I have no idea what can be integrated in DW or already is.


uxk8396
Hi,
Thank you for the prev reply.
I tried using margin:auto in my CSS file to get the navigation (se attached file in previous post) but could not do it. Am I missing some step here, for instance to creating a container
first, set its width and height, center it and then position the nav inside the container. I am confused, please advise.

pandy
Do you want it centered on the page? Then don't float it left.
uxk8396
Hi,
I still cannot get the navigation to be on the centered on the screen. Please take a look at the attachment to suggest where I am going wrong.
Thanks again blink.gif
uxk8396
QUOTE(uxk8396 @ Oct 12 2008, 01:47 PM) *

Hi,
I still cannot get the navigation to be on the centered on the screen. Please take a look at the attachment to suggest where I am going wrong.
Thanks again blink.gif



I got it to work finally by setting the width of the #nav to 585 px, and margin:auto

Thank you

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.