Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Posts
    310
    Thanks
    86
    Thanked 3 Times in 3 Posts

    7 Simple CSS Questions...

    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.

  • #2
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    Hey stfc_boy,

    Quote Originally Posted by stfc_boy View Post
    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. 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

  • Users who have thanked rmedek for this post:

    stfc_boy (10-24-2007)

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,471
    Thanks
    6
    Thanked 980 Times in 953 Posts
    Quote Originally Posted by rmedek View Post
    5) FF is not keen on comments in your CSS site?
    Not that I know of. 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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •