CSS Code Efficency

Discussion in 'CSS' started by wd_2k6, Oct 4, 2008.

  1. #1
    Hi,

    I''d be greatful if somebody could clear up some of the questions that have been floating around latley when i'm creating my CSS:

    1. How would you go about defining border around 3 edges and not the 4th:
    a) border: 1px solid #000; border-top: none;
    b) border-left: 1px solid #000; border-bottom: 1px solid #000; border-right: 1px solid #000;
    I'm assuming A wouldn't cause any problems?

    2. When creating your own CSS sheets, not for clients, would it matter as much to space things out properly i.e
    .notarelevantclassname{background:blah;border:blah;padding:50px;margin:200px;}
    Apart from the fact that it will be harder to debug later..

    3. When people link to CSS I always use <link rel="stylesheet" /> however I often seen some import @url or something like that, what's this all about?

    4. Lastly it's SEO and CSS question I guess, is it considered blackahat or could I get peanlised for stating:
    strong { font-weight: normal; } It's just I hate how bold text looks within a paragraph but it adds a tiny bit of emphasis for the SE..

    If you could answer 1 2 or even 3 questions it would be appreciated, as my curiousity is never-ending...
     
    wd_2k6, Oct 4, 2008 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    1)a
    2)whatever makes you happy, I would try to group like statements on their own lines though.
    3)I use link. @import is to trick specific browsers. Also if someone saves the page locally, @imports won't get the stylesheet.
    4)Nothing wrong with that. Doubt it will give a real SEO benefit though.
     
    shallowink, Oct 4, 2008 IP
  3. steelfrog

    steelfrog Peon

    Messages:
    537
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    1. I use the first method you've highlighted; it keeps the code much cleaner and is fully compliant as long as you define your default borders before you remove the top one.

    2. I prefer to keep my CSS clean and easy to edit unless I'm working on a very large site that gets a ton of bandwidth consumption.

    3. The @import method does not work in some older browsers, notably Netscape, IE3, IE4 and a few others, depending on how you do it. I just use the "link" method and don't bother debugging for those older browsers since very few (if any) people still use them, especially in my target audience.

    4. As far as I know, you would not get penalized but some smarter readers may not see the fake-bold text and negate it. You could also try creating a class for it so that it doesn't impede over standard strong tags: strong.hidden { font-weight: normal; }
     
    steelfrog, Oct 6, 2008 IP
    wd_2k6 likes this.
  4. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks shallowink and steelfrog, i'll take these points on board your opinions are resepcted. I'll proceed to using method A for the borders, keeping cleaner spaced code, stick to the link method for my external CSS and also try implementing my secret bold technique!!

    Steelfrog I also checked your site out, can I say congratulations on such a sexy blog, and some nice tutorials!!
     
    wd_2k6, Oct 7, 2008 IP
  5. buzzmaker

    buzzmaker Peon

    Messages:
    103
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    No problem with
    strong { font-weight: normal; }

    I don't know how good would it help SEO purpose.
     
    buzzmaker, Oct 7, 2008 IP