• sacbuntchris@lemmy.world
      link
      fedilink
      English
      arrow-up
      23
      ·
      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
        4
        ·
        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
          16
          ·
          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

  • wise_pancake@lemmy.ca
    link
    fedilink
    arrow-up
    22
    arrow-down
    2
    ·
    8 months ago

    I miss when CSS was tables. Now I don’t even recognize it with variables and compilers.

    • Strawberry@lemmy.blahaj.zoneOP
      link
      fedilink
      arrow-up
      6
      ·
      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

      • wise_pancake@lemmy.ca
        link
        fedilink
        arrow-up
        2
        ·
        8 months ago

        I do like flex layout, it’s very cool!

        I’ve been out of the css game for a while though, so now I’m totally lost