Home >Web Front-end >CSS Tutorial >Is Leaving Out Semicolons in CSS Good Practice?
Is it Good Practice?
Manually excluding semicolons is discouraged due to its potential for errors. Adding new styles without a semicolon may result in previous declarations not working as intended.
Load Time Performance
Removing semicolons can save bytes, particularly for large style sheets. However, using a CSS compressor is a more practical approach to optimizing performance.
Browser Compatibility
CSS browsers correctly implement this part of the specification. A declaration in CSS2 consists of a property name followed by a colon and a value, and multiple declarations for the same selector can be separated by semicolons. However, the semicolon is not required to terminate a declaration.
JavaScript Last Function
This rule does not apply to JavaScript, which has a different specification.
The above is the detailed content of Is Leaving Out Semicolons in CSS Good Practice?. For more information, please follow other related articles on the PHP Chinese website!