Use of external style sheets in Drupal 7

External style sheets can't be added in the themes .info file

In Drupal 7, drupal_add_css is used to add external style sheets. In this example, the minified Bootstrap's CSS is fetched.


/**
 * Implements template_preprocess_html().
 */
function subtheme_preprocess_html(&$variables) {
  drupal_add_css('https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css', 
    array('type' => 'external'));
}

Also, externally hosted style sheets are never aggregated or compressed.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.