diff --git a/lib/exe/css.php b/lib/exe/css.php
index dd69c94cfad60d40f385ac3f108792e1a8a56613..ae160558a149a5806d04dd6e8cf32d4605bc472a 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -58,8 +58,7 @@ function css_out(){
     // load template styles
     $tplstyles = array();
     if ($styleini) {
-        $ini = parse_ini_file($styleini, true);
-        foreach($ini['stylesheets'] as $file => $mode) {
+        foreach($styleini['stylesheets'] as $file => $mode) {
             $tplstyles[$mode][$tplinc.$file] = $tpldir;
         }
     }
@@ -74,8 +73,8 @@ function css_out(){
     $files = array();
 
     $cache_files = getConfigFiles('main');
-    if ($styleini)
-        $cache_files[] = $styleini;
+    $cache_files[] = $tplinc.'style.ini';
+    $cache_files[] = $tplinc.'style.local.ini';
     $cache_files[] = __FILE__;
 
     foreach($mediatypes as $mediatype) {
@@ -180,21 +179,31 @@ function css_applystyle($css,$tplinc){
     $styleini = css_styleini($tplinc);
 
     if($styleini){
-        $ini = parse_ini_file($styleini,true);
-        $css = strtr($css,$ini['replacements']);
+        $css = strtr($css,$styleini['replacements']);
     }
     return $css;
 }
 
 /**
- * If either exist, get the template's style.local.ini or style.ini file.
+ * Get contents of merged style.ini and style.local.ini as an array.
+ *
+ * @author Anika Henke <anika@selfthinker.org>
  */
 function css_styleini($tplinc) {
-    if(@file_exists($tplinc.'style.local.ini'))
-        return $tplinc.'style.local.ini';
-    if(@file_exists($tplinc.'style.ini'))
-        return $tplinc.'style.ini';
-    return '';
+    $styleini = array();
+
+    foreach (array($tplinc.'style.ini', $tplinc.'style.local.ini') as $ini) {
+        $tmp = (@file_exists($ini)) ? parse_ini_file($ini, true) : array();
+
+        foreach($tmp as $key => $value) {
+            if(array_key_exists($key, $styleini) && is_array($value)) {
+                $styleini[$key] = array_merge($styleini[$key], $tmp[$key]);
+            } else {
+                $styleini[$key] = $value;
+            }
+        }
+    }
+    return $styleini;
 }
 
 /**
diff --git a/lib/tpl/default/style.ini b/lib/tpl/default/style.ini
index b9e1e9424d80e6d6e0d16381d89db81cb3e7e944..726c2025d28dfb48774b965716f2746d11bf663e 100644
--- a/lib/tpl/default/style.ini
+++ b/lib/tpl/default/style.ini
@@ -1,8 +1,10 @@
 ; Please see http://www.php.net/manual/en/function.parse-ini-file.php
 ; for limitations of the ini format used here
 
-; Please only make changes in style.local.ini. If it doesn't exist,
-; just create it by copying style.ini.
+; To extend this file or make changes to it, it is recommended to create
+; a style.local.ini file to prevent losing any changes after an upgrade.
+; Please don't forgot to copy the section your changes should be under
+; (i.e. [stylesheets] or [replacements]) into that file as well.
 
 ; Define the stylesheets your template uses here. The second value
 ; defines for which output media the style should be loaded. Currently
diff --git a/lib/tpl/dokuwiki/style.ini b/lib/tpl/dokuwiki/style.ini
index bcb5a1a2e6ccde3a9c6ec167de69cad7761aced7..86066fa3b1c5b7eaa509c750174d4bd4b1a0c31c 100644
--- a/lib/tpl/dokuwiki/style.ini
+++ b/lib/tpl/dokuwiki/style.ini
@@ -1,8 +1,10 @@
 ; Please see http://www.php.net/manual/en/function.parse-ini-file.php
 ; for limitations of the ini format used here
 
-; Please only make changes in style.local.ini. If it doesn't exist,
-; just create it by copying style.ini.
+; To extend this file or make changes to it, it is recommended to create
+; a style.local.ini file to prevent losing any changes after an upgrade.
+; Please don't forgot to copy the section your changes should be under
+; (i.e. [stylesheets] or [replacements]) into that file as well.
 
 ; Define the stylesheets your template uses here. The second value
 ; defines for which output media the style should be loaded. Currently