...

View Full Version : 7 Simple CSS Questions...



stfc_boy
10-20-2007, 10:53 AM
Hi Guys,

While i'm starting to learn CSS I have a few questions that i've come across that I would appreciate help with that would help me understand CSS more:

1) ID elements are in the main used for columns in your CSS i.e. #leftcolumn, #main, #rightcolumn?

2) Span tags are generally used to style fonts?

3) Using a ID within an id is not good practice??? in ID's there should be div elements?

4) Do you have to specify margin:0 and border:0 in a style even though they are not set?

5) FF is not keen on comments in your CSS site?

6) Bold tags are frowned upon in the validator, but using <strong> is ok?

7) If I have three div boxes in a #middle of 300px and each of them are 100px and I want to display them inline with each other do I need to specify 'display:inline' in each of those three elements.

rmedek
10-20-2007, 12:30 PM
Hey stfc_boy,


1) ID elements are in the main used for columns in your CSS i.e. #leftcolumn, #main, #rightcolumn?

They can be used for that, but really an ID can be used any way you want to. They're there so you can "flag" elements and target them with stylesheets. You can put an ID on any element that needs it: <div id="main">, <ul id="navigation">, <dl id="gallery">, whatever.


2) Span tags are generally used to style fonts?

Span tags are meaningless elements—it's an empty HTML tag. You use them to surround inline elements like text, which is why so many people use them as style hooks for fonts. You would wrap text with a <span> tag, then target that <span> with CSS.


3) Using a ID within an id is not good practice??? in ID's there should be div elements?

Nope, go right ahead and nest IDs—remember, IDs aren't elements, they're just attributes in an element. In other words, if you can nest it in HTML, it's no problem if those HTML tags have IDs. Just remember you can only have one unique ID per page; i.e., only one "#main" or "#nav" or "#whatever".


4) Do you have to specify margin:0 and border:0 in a style even though they are not set?

Nope. Some people do that globally so they have a "clean slate" when they start the CSS process. Most of the time you'll end up using rules like this to overwrite the default browser styles.


5) FF is not keen on comments in your CSS site?

Not that I know of. :confused: I comment the heck out of my HTML/CSS.


6) Bold tags are frowned upon in the validator, but using <strong> is ok?

No, bold tags are valid. But it's recommended not to use them because <b> is a presentational tag while <strong> is a semantic tag, which is the whole point of using CSS in the first place.


7) If I have three div boxes in a #middle of 300px and each of them are 100px and I want to display them inline with each other do I need to specify 'display:inline' in each of those three elements.

Yes. Or, you could float them, either way will work.

Hope all this helps. Take some time to read the FAQs in this thread, too—there's a lot of useful info there.

-Rich

VIPStephan
10-20-2007, 03:35 PM
5) FF is not keen on comments in your CSS site?
Not that I know of. :confused: I comment the heck out of my HTML/CSS.

Well, I had the strange occurrence lately that an Umlaut (ä, ö, ü) as last character in a CSS comment in my stylesheet would make the following style not rendered. That was in IE, though. Other than that comments are perfectly fine in any browser. That must have been among the first things browsers were supporting.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum