function drupal_get_css

cis7 drupal_get_css($css = NULL, $skip_alter = FALSE)
cle7 drupal_get_css($css = NULL, $skip_alter = FALSE)
elmsmedia7 drupal_get_css($css = NULL, $skip_alter = FALSE)
icor7 drupal_get_css($css = NULL, $skip_alter = FALSE)
meedjum_blog7 drupal_get_css($css = NULL, $skip_alter = FALSE)
mooc7 drupal_get_css($css = NULL, $skip_alter = FALSE)

Returns a themed representation of all stylesheets to attach to the page.

It loads the CSS in order, with 'module' first, then 'theme' afterwards. This ensures proper cascading of styles so themes can easily override module styles through CSS selectors.

Themes may replace module-defined CSS files by adding a stylesheet with the same filename. For example, themes/bartik/system-menus.css would replace modules/system/system-menus.css. This allows themes to override complete CSS files, rather than specific selectors, when necessary.

If the original CSS file is being overridden by a theme, the theme is responsible for supplying an accompanying RTL CSS file to replace the module's.


$css: (optional) An array of CSS files. If no array is provided, the default stylesheets array is used instead.

$skip_alter: (optional) If set to TRUE, this function skips calling drupal_alter() on $css, useful when the calling function passes a $css array that has already been altered.

Return value

A string of XHTML CSS tags.

See also


12 calls to drupal_get_css()
advagg_build_ajax_js_css in sites/all/modules/ulmus/advagg/advagg.module
Gets the core CSS/JS included in this ajax request.
ajax_render in includes/
Renders a commands array into JSON.
imce-page.tpl.php in sites/all/modules/ulmus/imce/tpl/imce-page.tpl.php
login_shadowbox_page.tpl.php in sites/all/modules/local_contrib/shadowbox/login_shadowbox/login_shadowbox_page.tpl.php
overlay_deliver_empty_page in modules/overlay/overlay.module
Prints an empty page.

... See full list


includes/, line 3052
Common functions that many Drupal modules will need to reference.


function drupal_get_css($css = NULL, $skip_alter = FALSE) {
  if (!isset($css)) {
    $css = drupal_add_css();

  // Allow modules and themes to alter the CSS items.
  if (!$skip_alter) {
    drupal_alter('css', $css);

  // Sort CSS items, so that they appear in the correct order.
  uasort($css, 'drupal_sort_css_js');

  // Provide the page with information about the individual CSS files used,
  // information not otherwise available when CSS aggregation is enabled. The
  // setting is attached later in this function, but is set here, so that CSS
  // files removed below are still considered "used" and prevented from being
  // added in a later AJAX request.
  // Skip if no files were added to the page or jQuery.extend() will overwrite
  // the Drupal.settings.ajaxPageState.css object with an empty array.
  if (!empty($css)) {
    // Cast the array to an object to be on the safe side even if not empty.
    $setting['ajaxPageState']['css'] = (object) array_fill_keys(array_keys($css), 1);

  // Remove the overridden CSS files. Later CSS files override former ones.
  $previous_item = array();
  foreach ($css as $key => $item) {
    if ($item['type'] == 'file') {
      // If defined, force a unique basename for this file.
      $basename = isset($item['basename']) ? $item['basename'] : drupal_basename($item['data']);
      if (isset($previous_item[$basename])) {
        // Remove the previous item that shared the same base name.
      $previous_item[$basename] = $key;

  // Render the HTML needed to load the CSS.
  $styles = array(
    '#type' => 'styles',
    '#items' => $css,

  if (!empty($setting)) {
    $styles['#attached']['js'][] = array(
      'type' => 'setting',
      'data' => $setting,

  return drupal_render($styles);



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.