3

Possible Duplicate:
How important is it to leave out the last ';' inside a set of CSS rules?

If the IDE by default is adding ; at the end, should I remove it?

selector {property:value;property:value;property:value;property:value;}

I read in an article that a semicolon is not required at the end.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jitendra Vyas
  • 148,487
  • 229
  • 573
  • 852

6 Answers6

13

True, it is not required, but I like to leave it in case I want to add any more attributes later. The page weight that it reduces by removing these is negligible.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Zac
  • 12,637
  • 21
  • 74
  • 122
  • I read on another article "removing unneeded semicolon reduce the size of css" – Jitendra Vyas Mar 09 '10 at 04:48
  • 2
    true it does but unless your css files are really, really massive it is only going to amount to a "handful" of kB... run your file through a CSS Tidy if you want to see the difference – Zac Mar 09 '10 at 04:51
  • 1
    I agree; I always keep those ending semi-colons for ease of adding more attributes later. – contactmatt Mar 09 '10 at 05:49
  • Yeah, i prefer to leave the last simicolan too, coz it doesn't affect the file size that much. Reducing quality of an image can benefit the load time more than that. – nasty Aug 30 '12 at 23:21
  • i leave them for consistency. i'm kinda ocd that way. – peter Sep 11 '12 at 07:18
1

On the minified version you should remove it.

Fitzchak Yitzchaki
  • 9,095
  • 12
  • 56
  • 96
0

Either way, it won't affect your styles.

Wayne
  • 1,288
  • 1
  • 7
  • 20
0

Well.. as you said, it's not required, but no one said, it can not be there... the IDE just adds it, so when you want to add another property, you don't have to add a semicolon.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
fazo
  • 1,807
  • 12
  • 15
0

Yes, it is not required, but for consistency and best practices, just add it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
hallie
  • 2,760
  • 19
  • 27
0

It is not required by the specification, but, strangely enough, the YUI compressor always adds these semicolons to my CSS files :/ I had to write an additional script for deleting them each time.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Webmezha
  • 117
  • 1
  • 8