Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By syquest on
My theme’s style.css file is quickly growing into something monstrous. So I would like to break it apart into easy to manage, custom style sheets that control specific elements, such as type.css, color.css, graphics.css, etc. My question is:
How do I add (import) custom style sheets to my themes template.php file.
Is that a PHP function? What would that code look like?
All comments and suggestions would be greatly appreciated.
Comments
theme_add_style
Hi syquest,
to import your own styles into your theme put the following code into your template.php:
and it should work.
---------------------------------------------
last projects: www.happy-faces.de - www.3p-consulting.com
Doesn't seem to work
Danke schön for your suggestion, but it isn't working for me.
When I include the style h2 color: red in style.css the style applies to the output: all h2s are red.
However if I...
(1) remove that style from style.css;
(2) place it in a new file, type.css;
(3) then add the PHP code, as you suggest above, to template.php
... the resulting output contains blue h2s, their default color. What am I doing wrong?
It works with minor adjustment
I had to add a path...
...and now it works like a charm.