Challenge Yourself, Even When It’s Art
Tags: html, css, art, books
Published: 2023-01-10 19:52:11

Art is great, when craft triggers emotion and our sense for aesthetics is stimulated to connect with the force of life. You don’t want to read me go on about art, probably (though if you do, here are <a href="https://cse.google.com/cse?cx=007435340685329731950%3Auo6twvdbp_m&q=art">some old articles</a> that will change your mind), so let’s talk about HTML, and CSS, and both being used <em>for</em> art.

What could go wrong? This is a chapter from my latest book, <a href="https://meiert.com/en/blog/upgrade-your-html-4/"><cite>Upgrade Your HTML IV</cite></a>.

<blockquote>
<pre><code>&lt;div&gt;
  &lt;div class="one" style="left: 0; top: 0; background: linear-gradient(90deg, #2b2a27, #453f04);"&gt;&lt;/div&gt;
  &lt;div class="one" style="left: 50vw; top: 0; background: linear-gradient(90deg, #2b2a27, #453f04);"&gt;&lt;/div&gt;
  &lt;div class="one" style="left: 0vw; top: 50vh; background: linear-gradient(90deg, #453f04, #2b2a27);"&gt;&lt;/div&gt;
  &lt;div class="one" style="left: 50vw; top: 50vh; background: linear-gradient(90deg, #453f04, #2b2a27);"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="two_cont"&gt;
  &lt;div class="two" style="left: 10vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 20vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 30vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 40vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 50vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 60vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 70vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 80vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 90vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 10vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 20vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 30vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 40vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 50vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 60vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 70vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 80vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 90vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 10vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 20vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 30vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 40vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 50vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 60vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 70vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 80vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 90vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 10vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 20vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 30vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 40vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 50vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 60vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 70vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 80vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="two" style="left: 90vw; top: 90vh;"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="three_cont"&gt;
  &lt;div class="three" style="left: 10vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 20vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 30vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 40vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 50vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 60vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 70vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 80vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 90vw; top: 10vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 10vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 20vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 30vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 40vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 50vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 60vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 70vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 80vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 90vw; top: 37vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 10vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 20vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 30vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 40vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 50vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 60vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 70vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 80vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 90vw; top: 64vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 10vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 20vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 30vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 40vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 50vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 60vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 70vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 80vw; top: 90vh;"&gt;&lt;/div&gt;
  &lt;div class="three" style="left: 90vw; top: 90vh;"&gt;&lt;/div&gt;
&lt;/div&gt;</code></pre>

<p>Did you catch it? Line 4 <ins>[which is numbered in the book]</ins> uses a unit even though the value for <code>left</code> is <code>0</code>. In all other cases, the author had removed the unit. (Interesting article, on this note, which appeared right around the time of writing of this chapter: <a href="https://www.oddbird.net/2022/08/04/zero-units/"><cite>Not All Zeros Are Equal</cite>.</a>)</p>

<p>What is going on here, and what can we do about code like this?</p>

<p>The example is… art. CSS art. CSS art, you can say (<a href="https://meiert.com/en/blog/the-css-art-paradox/">I do say</a>), comes with a paradox:</p>

<blockquote>
<p>The most sophisticated CSS being applied to the most meaningless, bloated, and unmaintainable HTML; i.e., the best CSS on top of the worst HTML: That is <em>the paradox of CSS art</em>.</p>
</blockquote>

<p>This paradox seems to assume the artist has a free pass for the quality of their code. Or does it?</p>

<p>I believe there are three possible answers to this:</p>

<ol>
<li>Yes, if it’s CSS art, then code quality is secondary and probably doesn’t matter.</li>
<li>CSS art, as code, should still be held to a standard, reviewed, and optimized.</li>
<li>No, artistic freedom should be limited to one dimension or language, i.e., to CSS; the HTML code should be of high quality, preferably consisting of only one element.</li>
</ol>

<p>(What do you think? Do you see more options? Let me know or tag me if you write about it somewhere!)</p>

<p>Personally, I can respect and work with all three responses. I prefer, however, if people challenge themselves, if they’re ambitious, if they don’t just go the easy route. As such, I like single-element art that works with minimal, neatly ordered CSS the most.</p>

<p>How would we optimize the code according to the three responses?</p>

<p>With 1., we can stop right here, and not even bother about that odd <code>0vw</code>. Artistic freedom.</p>

<p>With 2., we would clean up. I wouldn’t challenge the need for all elements here—maybe they’re not all needed, but let’s assume so—, but I would challenge the need for the class names as well as the <code>style</code> attributes. For both, <a href="https://meiert.com/de/publications/articles/20050107/">use context</a>, and work through the list with, for example, <a href="https://www.w3.org/TR/selectors-4/#adjacent-sibling-combinators">adjacent sibling selectors</a> or <a href="https://www.w3.org/TR/selectors-4/#child-index">child-indexed pseudo-classes</a>. I’d garnish the parent element with an ID (this book series is a safe space for IDs). And yes, this has been a bad case of divitis, so here, let’s only list up to five <code>div</code> child elements:</p>

<pre><code>&lt;div id=art-challenge&gt;
  &lt;div&gt;
    &lt;div&gt;&lt;/div&gt;
    &lt;div&gt;&lt;/div&gt;
    &lt;div&gt;&lt;/div&gt;
    &lt;div&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div&gt;
    &lt;div&gt;&lt;/div&gt;
    &lt;div&gt;&lt;/div&gt;
    &lt;div&gt;&lt;/div&gt;
    &lt;div&gt;&lt;/div&gt;
    &lt;div&gt;&lt;/div&gt;
    &lt;!-- … --&gt;
  &lt;/div&gt;
  &lt;div&gt;
    &lt;div&gt;&lt;/div&gt;
    &lt;div&gt;&lt;/div&gt;
    &lt;div&gt;&lt;/div&gt;
    &lt;div&gt;&lt;/div&gt;
    &lt;div&gt;&lt;/div&gt;
    &lt;!-- … --&gt;
  &lt;/div&gt;
&lt;/div&gt;</code></pre>

<p>For 3., that’s easy:</p>

<pre><code>&lt;div id=art-challenge&gt;&lt;/div&gt;</code></pre>

<p>—but it may also make it impossible to achieve the desired effect.</p>

<p>Artists themselves can do our field a favor and set expectations: Do they take all freedom and don’t care about quality? Do they aim for reasonably optimized code? Or do they set the highest bar possible for themselves, and leave a minimal HTML footprint?</p>

<p>The paradox of CSS art doesn’t need to be mysterious: Challenge yourself, even when it’s art.</p>
</blockquote>

<a href="https://meiert.com/en/blog/upgrade-your-html-4/" class="media alt"><img src="https://meiert.com/de/publications/books/upgrade-your-html-4/cover-s.png" alt="The cover of “Upgrade Your HTML IV.”" /></a>

Thank you for reading. If you liked this, <a href="https://meiert.com/en/blog/upgrade-your-html-4/">check out the book</a>; if you <em>loved</em> this, check out the series (<a href="https://www.amazon.com/dp/B094W54R2N/?tag=j9t-21-20">Amazon</a>, <a href="https://www.kobo.com/us/en/search?query=Upgrade%20Your%20HTML&amp;fcsearchfield=Series&amp;seriesId=bb8e84b2-1033-5b20-8fcd-91a5e31e8713">Kobo</a>, <a href="https://play.google.com/store/books/series?id=5AksGwAAABDJEM">Google Play Books</a>, <a href="https://leanpub.com/b/upgrade-your-html-1-4">Leanpub</a>). Enjoy!