Technology News

Inline Styles as Classes (lol)

If you’re abhorred by using inline styles, just move that style to the class attribute! And then make sure you have CSS in place that, ya know, does what it says on the box.

OK lemme dig in and totally ruin the joke.

  • First off, it’s a joke, so don’t actually do this. I don’t even mind the occasional inline style for one-off stuff, but this is not that.
  • To me the weirdest part is that period (.) character. Escaping the more unusual characters with a backslash () feels normal, but what is that period about? UPDATE: It’s because of the space. It’s two classes in the HTML, not one. Derp.
  • The little period trick there doesn’t work when the following character is a number (e.g. .padding:.1rem;). UPDATE: Because classes that start with a number are invalid. Derp.
  • You can avoid the escaping and trickery if you go with an attribute selector like [class*="display: flex;"].
  • This reminds me of Mathias Bynens’ research: CSS character escape sequences. But… that doesn’t seem to work anymore? I wonder if browsers changed or if the tool broke and doesn’t output what it should anymore (e.g. does .color3A #f06d06 look right?).

Here’s all that playing around:

Biden says Putin “knows there are consequences” if cyberattacks continue
The problem with Facebook’s attempt to be more like Nextdoor

Related Articles

HTML is Not a Programming Language?

html-is-not-a-programming-language
HTML is not a programming language. I’ve heard that sentence so many times and it’s tiring. Normally, it is followed by something like, It doesn’t have logic, or, It is…

Why Learn Python?

Why Learn Python?
Why learn Python? Well, because it’s friendly and everywhere and here and popular and powerful and learnable and lucrative and fun. Why not learn Python? I should probably unpack that…

My petite-vue review

Exploring the Potential of the Metaverse: A New World Awaits
Road testing petite-vue with a simple category filter July 21, 2021 petite-vue is a new cut of the Vue project specifically built with progressive enhancement in mind. At 5kb, petite-vue…