Cascading Style Sheets (CSS) can be included in a Drupal site in various ways. Whether you want to include CSS files from a custom theme or an external library, you will need to understand the concept of asset libraries and how to use them to include CSS for your Drupal site. To add HTML attributes such as classes or IDs, you will need to know some Twig.
- Add CSS files from a theme or module to a Drupal site
- Add an external CSS library, such as a font or icon library, to a Drupal site
- Add static or dynamic attributes and classes in a Twig template file
Drupal 8 introduced new concepts and methods for adding CSS to Drupal. These methods are now established and not likely to change, although tips and tricks may emerge over time. Resources labeled for Drupal 8 should work for Drupal 9.
Learn what libraries are, how to define them, and how to attach an asset library. Use these concepts and skills to add CSS to your Drupal site.