tags:

views:

80

answers:

3

I've had problems with Internet Explorer not applying the last property in a list of CSS properties. Is it necessary to leave out the last ; from a list of CSS properties? For example:

.style { width: 100px; height: 100px }

Or does it really not matter?

+7  A: 

It doesn’t matter. Even Internet Explorer 6 will accept the redundant semi-colon at the end; your mistake must have been somewhere else.

Konrad Rudolph
no mistake. just curiosity in the name of good coding.
kalpaitch
@kalpaitch: You insinuated that you've had problems with IE not applying the last property, thus it *must* have been a mistake which lies somewhere else :)
BalusC
Ha I see, you have changed the question to air out the gramatical errors. You seem also to have changed the fact that I said I was having problems with the last ';' in a list of parameters - that was a separate issue I'm afraid. I was just curious to know if the same reflected a better way of writing CSS. Sorry for the confusion.
kalpaitch
A: 

You don't need to include the last semi-colon. Nor do you have to exclude it. It's optional.

From a maintenance point of view, I'd actually get into the habit of including after every property. Accidentally forgetting to put one one in when editing can cause some subtle errors.

I am not aware of any issue with IE causing issues with missing semi-colon's - either that was an awful long time ago or there was some other issue that maybe lead you to believe that was the problem ;)

Amadiere
+2  A: 

Additional advice: Be absolutely sure you don't accidentally end a line with double semicolons, like

.aStyle {
  background-color: #FFFFFF;;
  color: #000000;
}

This can have the extremely unhappy effect of negating every single style that comes after it on the page. It is not at all like an additional semicolon at the end of a line of Javascript, which has no effect whatsoever except to add a character to the page weight.

Robusto