The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS required: div class or id ?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #31299
    Attila Hajzer

    hey , just wondering, im making just a quick runndown static website and using html5. but remembered that in one of my previous posts that the HTML 5 wasn’t cross browser proper for me. i dont know it was mental!

    but here’s the code. so far


    This is the website title Inside the header

    This is the some quote or sloagen

    This may change per page.

    This may change per page.

    This may change per page.

    This may change per page.

    This is your footer copywrite section.

    so my real question was, should i be naming every div? (giving it an “ID” or “Class”?? if so ? howcome
    or why not?
    and is it good practice?


    So, heres what the difference between classes and IDs are.

    IDs are used for elements that don’t repeat (ones that you only have one of) such as #footer
    Classes are used for repeating things such as an LI element inside of a UL.

    Your code wont validate if you have more than one of the same ID on the same page.

    Hope that helps

    Rob MacKay

    You don’t HAVE to – depends what you want to do really.


    You don’t have to give it anything apart from the name

    however I fell it helps to know what the point of the div is for or how it is to be styled and so give it a meaningful id or class
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.