diff --git a/lib/weblib.php b/lib/weblib.php
index 7d572bd..aeb7c67 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -2401,7 +2410,21 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
 /// Add the required stylesheets
     $stylesheetshtml = '';
     foreach ($CFG->stylesheets as $stylesheet) {
-        $stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />'."\n";
+        if (is_string($stylesheet)) {
+            $stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" media="all"/>'."\n";
+        } elseif (is_array($stylesheet) && isset($stylesheet['href'])) {
+            $stylesheetshtml .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$stylesheet['href']}\"";
+            foreach($stylesheet as $attr => $value) {
+                $attr = strtolower($attr);
+                if ($attr == 'href') {
+                    continue;
+                }
+                $stylesheetshtml .= " $attr=\"$value\"";
+            }
+            $stylesheetshtml .= '/>';
+        } else {
+            error_log("Element of \$CFG->stylesheets was not a string nor an array : '" . print_r($stylesheet,1) . "'");
+        }
     }
     $meta = $stylesheetshtml.$meta;
