SDF Chatter
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Mac@programming.dev to CSS@programming.dev · 1 year ago

CSS variables

gomakethings.com

external-link
message-square
9
fedilink
13
external-link

CSS variables

gomakethings.com

Mac@programming.dev to CSS@programming.dev · 1 year ago
message-square
9
fedilink
Yesterday, I mentioned that I love CSS variables. Today, I thought I’d explain what they are and how they work, for those who aren’t already familiar with them. Let’s dig in! How to define CSS variables You define a CSS variable by typing its name with a leading double-dash (--). It uses the same syntax a typical CSS property—--{name}: {value}—and must be defined on an element. p { --size: 1rem; } You can then use your CSS variable just like you would any other property value by wrapping it in var().
alert-triangle
You must log in or register to comment.
  • stevedidwhat_infosec@infosec.pub
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Seems like a cool website, added to my list thanks!

  • Mathprogrammer1@sh.itjust.works
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Why not use SASS?

    • spartanatreyu@programming.dev
      link
      fedilink
      arrow-up
      7
      ·
      1 year ago

      Let me reverse that question and ask: Why use Sass?

      • Mathprogrammer1@sh.itjust.works
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        It has variables as well as modules, easily nestable definitions, and inheritance so that you can have base classes

        • spartanatreyu@programming.dev
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          CSS has variables, modules and nesting.

          By inheritance, do you mean the extends keyword? Because if so, it just seems like going further down the misguided BEM path instead of picking better selectors.

      • Maven (famous)@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        Sass is lovely. I love being able to split my CSS into multiple files in the same way I would split the rest of my code. It’s really nice for making more maintainable CSS on larger projects.

        My portfolio would’ve been hell to make without SASS helping with the organization.

        • spartanatreyu@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          CSS can already be split into multiple files though.

          So why not just use CSS?

        • 𝘋𝘪𝘳𝘬@lemmy.ml
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          Sass is to CSS what jQuery is to Javascript.

    • 𝘋𝘪𝘳𝘬@lemmy.ml
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      The same reason you don’t start new projects using jQuery.

CSS@programming.dev

css@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !css@programming.dev
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 1 user / day
  • 2 users / week
  • 10 users / month
  • 21 users / 6 months
  • 1 local subscriber
  • 547 subscribers
  • 103 Posts
  • 57 Comments
  • Modlog
  • mods:
  • Ategon@programming.dev
  • BE: 0.19.8
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org