SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot mattyj's Avatar
    Join Date
    Mar 2004
    Location
    Western Australia
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Global styles;; class or id

    you know when you're setting up your (global) styles for links (a hrefs), should you use 'class' or 'id', or does it matter?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Use ID if the element is only going to be used once on the page. IDs are supposed to be unique. If the element is going to be used more than once, use a class instead.

    Think back to school: Your name is Matt J. You're unique. When you have 20 other students in with you, you're in class.

    Edit:


    If you're going to set up styles for all links at once, just style the a tag rather than using classes or IDs. Example:
    Code:
    a {
      font-weight: bold;
      color: #282828;
      text-decoration: underline;
    }

  3. #3
    SitePoint Zealot mattyj's Avatar
    Join Date
    Mar 2004
    Location
    Western Australia
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm I fancy your analogy..

    so the use of an ID is really a crossover into programming territory because it is obviously used for any coding I take it, being unique and singular.

    while you're there;

    I've got a slightly older version of 'the dream' that likes to insert 'name' elements for form elements when I do rapid dev;

    <input name="#" type="checkbox" value="#" checked="checked" title="glossary: Distributorship Terminology" />

    does the name still stand (ie can you confirm that id hasn't replaced it)

    the thing about the a I'll have to analyse more, I have in my design 4 link types:
    1. Default Embedded instances: these instances do not have their own font style definition (adopts paragraph fomatting)
    2. Content Index instances (CI): these instances have their own font style definition
    3. Sidebar (Nav) instances (NV): these instances have their own font style definition
    4. Glossary Terms instances (GT): these instances have their own font style definition (I'm going to model Sitepoint and use a dashed underline effect for these)
    those are my links. I need to also figure out say if I want to modify tooltip text for all glossary links to a different title, this isn't a style is it and would require some extra magic outside of css.


Bookmarks

Posting Permissions

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