Add css to nodes of certain content type I've been trying to add css to a content type for a while, but I can't seem to find any help on this for drupal 8.

How do you add a library to only the nodes of a content type?

Thanks in advance!
The generic answer:

if (some condition) {
  $something['#attached']['library'][] = 'yourmodule/yourlibrary';
}


If you're in a module, do it in hook_node_view() and add it to $build. If you're in a theme, do it in hook_preprocess_node() and add it to $variables.

some_condition for your case would be $node-&gt;getType() == 'your_type', in case of preprocess, the node object is in $variables['node']

You can even do it directly within a template with attach_library(), see https://www.drupal.org/node/2456753.