www.webdeveloper.com
Results 1 to 6 of 6

Thread: How to layout markup and Css

  1. #1
    Join Date
    Oct 2003
    Posts
    205

    How to layout markup and Css

    Hi,

    I've been having a discussion with work collegues about the best way to do something and we've come to a disagreement... so I thought I would see what you think.

    Basically one side is saying that when creating their CSS its good to have lots of classes that can be used multiple times. E.g:

    Code:
    flLeft{
       float: left;
    }
    
    flRight{
       float: right;
    }
    
    topMargin10{
       margin-top: 10px;
    }
    etc. Then it could be used like this:

    Code:
    <p class="flRight">Some text goes here</p>
    
    OR
    
    <p class="mainText flRight">Some text goes here</p>
    The other side of people say that that is just adding unnecessary mark-up which would have to be changed if the site ever got re-designed and it would be much better to have it all in the element class itself. E.g.

    Code:
    p.mainText{
       color: #000;
       font-size: 1em;
       float: right
    }
    I hope that makes sense. So what do you think, which way do you think is the best way to do it?

    Thanks

    Phil

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    The best way is to use the mark up to describe the content and meaning of the page and then apply the CSS. You're goal is a page that can have any number of layouts applied to it by switching out the stylesheet.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Oct 2003
    Posts
    205
    So are you saying the second waqy of doing it would be the better of the two?

  4. #4
    Join Date
    Jun 2008
    Location
    Schaumburg, IL
    Posts
    16
    definitely the second.
    you want to be able to change more by doing less.
    the first technique requires you to change your actual html in more places than is necessary.

  5. #5
    Join Date
    Oct 2003
    Posts
    205
    kristingish,

    That's my thoughts to be honest, but I just wanted to see if anyone believes the first way is the better way and if so what their reasoning is.

  6. #6
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    It's pretty ridiculous to conclude one or the other in this case. The "better" styling depends on the particular document (or "family" of documents). It's like debating whether a flashlight or an ice-cold beer is better. It depends on what the hell you're trying to do! Do you want to light a room or have a damn drink?!

    If you're document(s) is/are complex enough to warrant this debate, my guess is that you'll have some elements that are best identified as mainText, and others that are better identified as emphasized leftish highHanging mainText, and still others are fine just being leftish or bakedOutOfTheirMinds.

    Know what I mean?
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles