Reader small image

You're reading from  Drupal 10 Masterclass

Product typeBook
Published inDec 2023
PublisherPackt
ISBN-139781837633104
Edition1st Edition
Tools
Concepts
Right arrow
Author (1)
Adam Bergstein
Adam Bergstein
author image
Adam Bergstein

Adam Bergstein is a product engineering leader and an architect. He has been a long-time Drupal community member, a routine speaker at Drupal community events around the globe, and provided keynotes for several events. He has maintained and contributed to many Drupal projects, including Password Policy, Taxonomy Menu, and more. Adam is the lead of Simplytest, a free service, and a project that offers Drupal community members testing sandboxes. He has also worked for both agencies building Drupal applications and Drupal service providers building Drupal-related products. He has led the Drupal Community Governance Task Force and is serving a term as a community board member of the Drupal Association.
Read more about Adam Bergstein

Right arrow

Working with CSS

Drupal expects specific conventions when it comes to implementing CSS. Typically, CSS files go into a themename/css directory, but that’s not necessary. Drupal themes are free to use Sass, PostCSS, or other build processes as they see fit.

For the theme to load a CSS file, the file must be referenced from a library. Then, the library must be called from either the themename.info.yml file, attached in preprocess, attached within the template through the attach_library function, or loaded by a module.

Drupal core has a set of CSS standards that requires the use of block element modifier (BEM) architecture. Generally, this is best practice within all themes, but it isn’t required. In addition, many popular utility-based CSS frameworks such as Tailwind or Bootstrap negate the need for BEM.

The basics of BEM is that you give your component (aka a “block”) a name. In this case, the name will be a card. Then, any elements inside of that...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Drupal 10 Masterclass
Published in: Dec 2023Publisher: PacktISBN-13: 9781837633104

Author (1)

author image
Adam Bergstein

Adam Bergstein is a product engineering leader and an architect. He has been a long-time Drupal community member, a routine speaker at Drupal community events around the globe, and provided keynotes for several events. He has maintained and contributed to many Drupal projects, including Password Policy, Taxonomy Menu, and more. Adam is the lead of Simplytest, a free service, and a project that offers Drupal community members testing sandboxes. He has also worked for both agencies building Drupal applications and Drupal service providers building Drupal-related products. He has led the Drupal Community Governance Task Force and is serving a term as a community board member of the Drupal Association.
Read more about Adam Bergstein