Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorsherman
    • CommentTimeAug 9th 2009
     permalink
    Can someone please tell me why designers use ID and CLASS names for the same element. For example :

    <body id ="wrapper" class ="anything">

    Please help?

    Thanks
    • CommentAuthorsumi
    • CommentTimeAug 9th 2009
     permalink
    Developers use ID if they have to perform some JavaScript or Dynamic function on the DIV where as they use class to style to item.

    Hope this clears..
    •  
      CommentAuthorTetsuo
    • CommentTimeAug 10th 2009
     permalink
    It is also useful if you want to modify an element using CSS for a particular page only.

    For example, if on a particular page you would like the element to be a different colour to all the other pages, you can simply add:

    .anything {color:red;}

    Rather than having to create a separate element, such as

    <body id="wrapper-newcolour">
  1.  permalink
    designers shouldn't be doing markup or css...they're designers :)

    but like others have stated, it is normally to further target a node on a given page...though...it doesn't really make much sense to assign the <body> node an id as it's the only node of its kind on any html document.
  2.  permalink
    Programmers seems have tendency to overthink and overcomplicate things
    creating unncessary classes and nested containers. I personally like to keep things simple.

    The only case I would use <body id="foo"> it's to overwrite some existing style properties based per page.
    For instance, you already build the template structure and all major layout styling properties are done but you need an extra page which has few own tweaks so you can add new divs etc or you can add unique id to body of the document then overwrite style properties but it really depends on individual situation.

    Cheers, DS
Add your comments
    Username Password
  • Format comments as (Help)