Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

<noob> Html/CSS question </noob>

Options
  • 09-07-2009 1:42pm
    #1
    Closed Accounts Posts: 81 ✭✭


    Hello all,

    I've just started messing about with some html and css now that I've finished secondary school. Firstly I'm slightly confused with when to use id and class terms and secondly when to use a table for layout or not.

    If the layout was going to be like this http://www.revisionworld.ie/ or http://www.collegehumor.com/ would I use a table to get the mainpage in the centre with the background image behind it? Sorry if I'm not even explaining myself well but we all have to start somewhere!

    Thanks in advance!


Comments

  • Closed Accounts Posts: 9,700 ✭✭✭tricky D


    id is for a unique element
    class may be reused

    use css for layout and typography, tables for tabular data

    better to post in Web Development & Design

    some tutorials on css and xhtml are over at http://www.w3schools.com

    hth


  • Closed Accounts Posts: 81 ✭✭Shoot-a


    thanks tricky
    i considered posting it there but it seemed less related to actual coding and this section seems a more likely hang out for hackers (http://catb.org/esr/faqs/hacker-howto.html#what_is)


  • Registered Users Posts: 342 ✭✭adm


    id's should be unique - so there should be no two elements with the same id.
    id is also used a lot in javascript to reference a particular element.

    classes are not unique - so you can have multiple elements of the same class and style them as a group.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    As was said, ID should be unique within a page, and it's particularly used for elements that should be the same across multiple pages.

    For e.g. if you wanted all of your pages to have 3 areas, a header, a main and a footer, you would use header, main and footer IDs. There'd only be one of each per page and every page would implement them.

    Classes are for things that will be repeated within a page, say a paragraph heading, you could have a particular class for that, and you may then have multiple paragraphs each with their own heading which use that class.

    There's no technical reason why you couldn't just use classes and ignore IDs altogether, but it makes for good practice to use them. Giving your HTML elements IDs is important, when you come to use javascript you'll use them a lot, and they help non-browser clients such as accessibility devices interpret the page. Since using IDs in HTML is good practice, it's also then good practice to take advantage of that with your CSS, it helps you to enforce a standardised look on your sites, a heading or a navigation bar or footer etc will look the same from page to page.


  • Closed Accounts Posts: 38 PixelPixie


    Your id and class question has already been answered by previous posters.
    As for layout, use xhtml and css - avoid using tables as they were originally only meant for display of tabular data and not for layout. In the absence of anything better designers began to use them from html3.2 onwards for layout. The almost universal adoption of the xhtml/css standard by browser makers (with the notable exception of M$ IE in many cases) has meant that tables need no longer be used for layout. Use the <div..> tag for that.
    xhtml and css is the way to go as it gets rid of a lot of bloat code and, when used properly, effectively separates content from design.
    As mentioned before W3Schools has some excellent resources to help.


  • Advertisement
Advertisement