This wiki was updated to MediaWiki 1.37. If you notice any issues, please report them to admin[at]

Help:CSS cleanup

Jump to: navigation, search

This page describes how to replace hardcoded "style=..." with proper CSS classes.

You can find more details in the mailing list archive.


  1. download all Template:* pages with the script below this section
  2. find templates using style= with grep -i style= templates/*
  3. take the styling from "style=...", find a proper CSS classname and write it to $page as a CSS class
    1. if the template is used as page template, store the exact style="..." code and the new classname on $otherpage - that makes it easier to cleanup those pages with search&replace later
  4. contact a wiki admin to move the CSS classes to MediaWiki:Common.css
  5. remove style= from all templates where you added class= before

Templates used as page templates

Templates used as page templates are listed in

Script to download all template pages

This script downloads all Template:* pages from Please use it only if you want to work on CSS cleanup to avoid useless server load.

# where to store the templates
### you shouldn't need to change anything below this line ###
test -d "$output_dir" || mkdir -p "$output_dir" || { echo "can't mkdir $output_dir"; exit 1; }
cd "$output_dir" || { echo "can't cd to $output_dir"; exit 1; }
set -o pipefail
# get template list
wget -q '' -O - | \
    sed -n '/<!-- Begin Content Area -->/,/<!-- End Content Area -->/ s/^<li><a href="\/\([^"]*\)".*/\1/p' | \
    grep -v '/doc$' > template-list.txt || { echo "error downloading the tempate list"; exit 1; }
echo "List of templates (excluding */doc) stored in template-list.txt."
# download templates
while read template ; do
    echo -n "downloading $template...   "
    outfile=$(echo "$template" | sed 's§/§+§g')
    test "$template" = "$outfile" || echo -n "(saved as $outfile)   "
    wget -q "$template&action=raw" -O "$outfile" && echo OK || { failures="$failures $template" ; echo failed; }
    sleep 1 # don't overload the wiki
done < template-list.txt
echo "Templates saved in $output_dir"
test -n "$failures" && echo "Download failures: $failures"