The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Proper Usage of Semicolons

  • # October 30, 2008 at 11:21 am

    I’ve always been under the impression that every css statement should end in a semicolon. However, many people use semi-colons simply as separators between two css statements. Which is the industry standard?

    I would do it like this:

    .myMethod { color: #8080ff; font-size: 14px; }

    but I’ve seen it like this

    .anotherMethod { color: #8080ff; font-size: 14px }

    Both seem to work in IE and FF. Does either cause a problem in any other browser?

    I prefer my method; it seems cleaner somehow. But I’d like to know which is "proper" technique.

    Edit: I realized what it is about the second method that bothers me… It’s like reading a book where the last sentence in every paragraph is missing a period. :)

    # October 30, 2008 at 9:08 pm

    This reply has been reported for inappropriate content.

    the semi colon is needed to seperate the properties from one another. The reason you should put the semi colon on the end is so that later if you want to add more rules, you won’t need to remember to add it in there. It’s better that way. Not adding it to the end of your line is lazy I think.

    # October 30, 2008 at 10:43 pm

    This reply has been reported for inappropriate content.

    I believe it is actually perfectly valid to leave off that last semicolon and actually would save you a tiny amount of bandwidth to omit it. But… I agree with cybershot, it’s ugly, it’s lazy, and it invites problems later on.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed