Spotlight CSS Injector

Drupal's theming system, which is introduced in Chapter 11, gives designers complete control over how a site's content is rendered for a web browser, and custom themes (like the Nitobe theme that we're using for the Super Duper Chefs site) can give any site a distinctive look. But sometimes it's useful to make minor tweaks to a site's appearance using nothing but CSS rules. They allow designers to tweak font sizes, colors, and so on without altering the underlying HTML that defines the site's structure.

The CSS Injector module ( gives administrators the ability to add those snippets in an administration screen within your site, without having to make changes to the current theme's files. This feature can be useful when a new version of your site's theme is released on—if you change the theme to add your own CSS, it's easy to lose those modifications when you download the new version. Keeping them in CSS Injector will preserve them even if you change themes.

CSS Injector offers a number of advanced options, including the ability to add the CSS rules conditionally on certain pages. If your CSS tweaks only apply to the front page, for example, you can ensure that it won't add the unnecessary rules to the entire site. You can also specify a media type for your CSS, which makes it possible to add styling information that applies only when a page is being printed. Finally, each rule can use the Preprocess CSS checkbox to control whether Drupal should merge its rules with the current theme's CSS. In most cases, this step saves time, because a visitor's web browser makes only a single trip to your site's web server to download all the stylesheets. If you're adding extremely large amounts of CSS code that only apply to one or two pages, it can be more efficient to keep that code separate by turning preprocessing off. Otherwise, leave it enabled.

If you're mystified by CSS, provides interactive work areas for learning all types of web technologies, including CSS. It's a great resource to keep bookmarked.

Was this article helpful?

0 0

Post a comment