XHTML & CSS Code Style
Version 8.1 by Ecaterina Moraru (Valica) on 2014/09/11 14:57
This document covers some basic conventions that are used in XWiki codebase. Please read over this document and make sure your code conforms to the rules here.
XHTML
The following rules must be followed:
- The HTML output produced by XWiki pages must be valid XHTML.
- The XWiki project is also following the W3C WCAG Guidelines. In addition we're also following the Dutch Web Guidelines which are even stricter than the WCAG ones.
CSS
The following rules must be followed:
- the CSS must be valid conform CSS 2.1 specification. This can be tested using the W3C CSS Validator
- don't use !important declarations
- don't use inline style declarations
- don't hard code colors in properties - use ColorTheme variables
- test your code on at least 3 browsers (IE, FF, Safari)
The following recommendations could be followed:
- Properties:
- alphabetical order
- 2 spaces indentation
- put a space between selector and declaration start, ex. "a {}"
- use of CSS shorthands
- use relative sizes (em, %) instead of fixed ones (px)
- use appropriate CSS files for writing IE rules
- limit as much as possible the number of IE hacks used
- Organization:
- comment headers for separation and grouping of different parts of the code
- Overwriting:
- document the localization of the overwrite using "Overwrites" and "Should be in" comments
Issues
- We currently don't have a naming convention
Tools
- Firebug
- CSS Optimizer and CSS Compressor are two excellent online tools that can shrink CSS
Testing
See the Testing page.