• sacbuntchris@lemmy.world
      link
      fedilink
      English
      arrow-up
      6
      ·
      8 months ago

      Interestingly, focus states are used in accessibility. So while this code isn’t to cure cancer, it likely does improve the lives of those with different needs.

      • Skullgrid@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        8 months ago

        it’s starting to make sense, what exactly does the meme want me to do about focus states so it can be read properly by screen reader software/used by keyboard navigation?

        • Strawberry@lemmy.blahaj.zoneOP
          link
          fedilink
          arrow-up
          5
          ·
          edit-2
          8 months ago

          CSS has a pseudo-class, :focus-visible, that matches when an element is focused using keyboard navigation. It also has :focus-within, which matches when the current focused element is the selected element or one of its descendents. However, this applies not only for keyboard navigation but also mouse and tap focus. A pseudo-class that combines the two, :focus-visible-within, would be useful, but does not currently exist. Here’s an article about it: https://larsmagnus.co/blog/focus-visible-within-the-missing-pseudo-class

          The code in the meme implements the logic of :focus-visible-within using the new :has() functional pseudo-class, and has a snippet of fallback behavior for slightly older browsers

      • idefix@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        8 months ago

        I feel like this article is completely missing my point. I’ve done my share of programming websites but not for the past 2 decades. And now I’m completely lost at reading CSS. I can’t make sense of the code shown in the picture. And that’s always been my trouble with CSS: the tendency to unnecessarily over-complicate things while reinventing the wheel. They have created a huge barrier for entry to the world of website programming and I think it’s a shame.

        • F04118F@feddit.nl
          link
          fedilink
          arrow-up
          0
          ·
          edit-2
          8 months ago

          That’s an honest criticism that does not intend to devalue frontend. But there’s an overlap where “over-complicate” may imply that frontend (tools) should be uncomplicated.

          Having only done a few frontend projects in recent years, I see obvious value to new, more powerful CSS selectors and even things like Tailwind. I can’t read Tailwind yet, but making intuitive user interfaces that work well on all kinds of devices for all kinds of people (screen readers?) is difficult and should not be expected to be simple, IMO. But this is a matter of opinion.

          The ones most qualified to deal with that issue are, obviously, experienced frontend devs and they build these things.

      • 𝕱𝖎𝖗𝖊𝖜𝖎𝖙𝖈𝖍@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        edit-2
        8 months ago

        Thanks for posting this.

        Good frontend work is HARD. It requires both design and engineering knowledge, and it’s very easy to write unmaintainable or inaccessible code. It also requires a high amount of backend work via BFFs, load balancing, hosting and serving, credential management, and more. The cherry on top is that it’s basically all async code.

        To be clear, I’m talking about the types of FEs used by thousands internationally, fully adherent to WCAG 2.2 (and above), and with rich interactivity. I’m not talking about someone’s hobby project with a couple dozen users at best.

        Seeing backend elitists diminish its worth is tiring as all hell. To me, it indicates that the person is either new to the industry or looking for a sense of superiority because they don’t understand FE work. It’s meaningless and exhausting to read.

        Tldr: I agree

      • Skullgrid@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        edit-2
        8 months ago

        I see you are a thin skinned idiot that can’t understand your own fucking link

        I find what most of those people actually mean is: HTML and CSS aren’t scripting languages. Which: a) of course they aren’t; and b) is not really the point at all.

        my point is that css is meant to determine appearance and logic should be handled elsewhere.

        • Strawberry@lemmy.blahaj.zoneOP
          link
          fedilink
          arrow-up
          0
          ·
          8 months ago

          CSS has always combined the styling and the logic for the styling. CSS selectors implement logic to determine where to apply styles

    • Strawberry@lemmy.blahaj.zoneOP
      link
      fedilink
      arrow-up
      1
      ·
      8 months ago

      It’s so much more fun now though! Things like grid layout and flex box have really changed the game. Also idk if you were saying otherwise but this has no variables and is vanilla CSS