<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>To Include or Not to Include CSS in Display Templates</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=111256808" />
  <subtitle>To Include or Not to Include CSS in Display Templates</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=111256808</id>
  <updated>2026-04-05T04:39:27Z</updated>
  <dc:date>2026-04-05T04:39:27Z</dc:date>
  <entry>
    <title>RE: To Include or Not to Include CSS in Display Templates</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111311542" />
    <author>
      <name>Olaf Kock</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111311542</id>
    <updated>2018-10-24T14:47:45Z</updated>
    <published>2018-10-24T14:47:45Z</published>
    <summary type="html">&lt;blockquote&gt;John CressmanWhat&amp;#39;s the best practice for using custom CSS in Display templates?  Is it a good idea?  Bad idea?&lt;br /&gt;&lt;br /&gt;There are certain instances where I can&amp;#39;t see how this is avoidable (setting the background of a div to the image in the structure), but what is the best way?&lt;br /&gt;&lt;br /&gt;I like the idea that the display template can basically be self-contained, with it&amp;#39;s own CSS, but then does that cause issues elsewhere?&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;I tend to go with my default answer: &amp;#34;It depends (TM)&amp;#34;&lt;br /&gt;&lt;br /&gt;If it&amp;#39;s positional (e.g. columns or embedding an image in text, floating) I lean towards embedded CSS. If it&amp;#39;s decorating with a specific color (that might be changed with the next CI/theme update, I lean towards not doing so. If the image that you mention is part of the content (e.g. an uploaded image): leaning towards yes. If it&amp;#39;s a design element (e.g. pretty border): No. &lt;br /&gt;&lt;br /&gt;To summarize: It depends. ;)&lt;br /&gt;&lt;br /&gt;After all, you&amp;#39;ll have to evaluate if the extra price for &amp;#34;doing it properly&amp;#34; is worth it - e.g. do you want to redeploy your theme? Do you even have control over it? Is this a one-off situation or a general strategy? I tend to solve &amp;#34;one-offs&amp;#34; on the spot, knowing that they can easily creep up to &amp;#34;one-more-offs&amp;#34; and &amp;#34;only-one-more-off-please&amp;#34;. When I realize that there&amp;#39;s now plenty of them, then it&amp;#39;s time to remodel and generalize. But I tend to not build a pretty and future-proof solution that is so unusual that nobody will ever be aware of either situation (neither the shortcut, nor the brilliantly architected version)</summary>
    <dc:creator>Olaf Kock</dc:creator>
    <dc:date>2018-10-24T14:47:45Z</dc:date>
  </entry>
  <entry>
    <title>To Include or Not to Include CSS in Display Templates</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111256807" />
    <author>
      <name>John Cressman</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111256807</id>
    <updated>2018-10-19T14:58:43Z</updated>
    <published>2018-10-19T14:58:43Z</published>
    <summary type="html">What&amp;#39;s the best practice for using custom CSS in Display templates?  Is it a good idea?  Bad idea?&lt;br /&gt;&lt;br /&gt;There are certain instances where I can&amp;#39;t see how this is avoidable (setting the background of a div to the image in the structure), but what is the best way?&lt;br /&gt;&lt;br /&gt;I like the idea that the display template can basically be self-contained, with it&amp;#39;s own CSS, but then does that cause issues elsewhere?&lt;br /&gt;&lt;br /&gt;​​​​​​​Thanks!</summary>
    <dc:creator>John Cressman</dc:creator>
    <dc:date>2018-10-19T14:58:43Z</dc:date>
  </entry>
</feed>
