Requests for comment/Deprecating inline styles

Currently the language MediaWiki uses to author documents allows the inclusion of html elements with style attributes. Mixing layout with content causes various problems with reusability, maintainability and is not future proof. Already on the mobile version of MediaWiki problems are being seen with inline styles with how pages render on smaller screens which could be solved via css3 media queries, however these cannot be done in inline styles. In addition to this the majority of things done in inline styles would be better done as class names for the purpose of consistency. For instance if we have text that is red (where 'red' is being used to serve a warning) this would be better down with a class warning otherwise some text risks being red whilst other text trying to express the same meaning may be a different tone of red (e.g. #BE3B3B)

To take a real example, various pages use inline styles to create two column layouts. Currently to fix portal page layouts we have every page that uses them. A preferred approach would be to make use of stylesheets and classes. This would mean that it would only take a change in one wiki page. Additional css rules could also be made to target more specific cases such as print and mobile layouts.

Possible solutions

 * Restrict allowed styles to MediaWiki:Common.css
 * Allow stylesheets per wiki page

Deprecating inline styles via the mobile site
The mobile site gets a smaller amount of traffic then the desktop site. It runs the MobileFrontend extension which includes a beta mode which is activated via the Mobile Settings page.

The mobile site is quite badly effected by inline styles. Various problems are described in Making_MediaWiki_Mobile_Friendly. It is proposed that turning off inline styles on the beta of the mobile site would be a good catalyst for reducing the use of inline styles across the website. The idea being that important and missing styles could be identified and defined in stylesheets, (initially MediaWiki:Common.css but on the long term potentially per page stylesheets. The long term goal would be to remove inline styles altogether in favour of these stylesheets on the main mobile site and then the desktop site. Note on the mobile site this all hinges on 34325.

Dissent?
''There are lots of different kinds of inline styles. Many are for color, font size, basic boxes, etc and work just fine.''

''The sort of styles that are most breakable on mobile are layout styles such as two-column layouts or floats/boxes being given a specific width or margin that doesn't fit well on a mobile screen. In addition, table layouts are often similarly problematic but would not be altered by this proposal, apparently.''

''What I do support is better ways to specify &lt;style> blocks in a page or template. This allows layout issues to be resolved with CSS media queries when they really really are needed, without cluttering up global styles for things used only in a few places.'' --brion (talk) 17:46, 2 July 2012 (UTC)