In Drupal 8, how can I add a class to teaser p html tag. I want to style the paragraph in teaser only, not when whole content is shown.


We can style that with simple css,

.node--view-mode-teaser .node__content p {
  /* write you style */

I think, you don't need to add separate class in P tag for that. and it would also affect only the teaser mode content :)

  • 1
    This answer is good, assuming he doesn't need to add a specific class name. Ex: Boostrap or Foundation class names. – No Sssweat Jul 16 '16 at 10:41

Assuming you're talking about the default front page teasers:

Edit the Frontpage view, and Instead of Show: Teaser, click on teaser and change it Show: Fields

Then you basically create your own custom teaser.

Add Fields: title, body (summary or trimmed), post date, comments link, etc...

enter image description here

Then click on Style Settings and the classes to your body (re-using pic from another answer)

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.