Falconry Party!
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
LemmyQuest@lemm.ee to Ask Lemmy@lemmy.world · 1 year ago

(Asking as someone who wants to create website) How to make website support dark mode without javascript?

lock
message-square
message-square
9
fedilink
22
message-square

(Asking as someone who wants to create website) How to make website support dark mode without javascript?

lock
LemmyQuest@lemm.ee to Ask Lemmy@lemmy.world · 1 year ago
message-square
9
fedilink
alert-triangle
You must log in or register to comment.
  • Nate@programming.dev
    link
    fedilink
    English
    arrow-up
    22
    ·
    edit-2
    1 year ago

    CSS prefers-color-scheme

  • RustyNova@lemmy.world
    link
    fedilink
    arrow-up
    11
    ·
    1 year ago

    This should help you

    https://css-tricks.com/a-complete-guide-to-dark-mode-on-the-web/

  • slazer2au@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    1
    ·
    1 year ago

    Use CSS

  • Leraje@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    1
    ·
    edit-2
    1 year ago

    If you’re not wanting to use JS then you’re reliant on the users browser supporting prefers-color-scheme (caniuse) or forcing them to reload the page.

  • Cloudless ☼@feddit.uk
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    1
    ·
    1 year ago

    <a href=“dark-page.html”>Dark Mode</a>

  • droning_in_my_ears@lemmy.world
    link
    fedilink
    arrow-up
    2
    arrow-down
    2
    ·
    edit-2
    1 year ago

    You can style both dark mode and light mode with CSS but the question is how will you toggle between them? A button? Then you need JavaScript

    • Zak@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      1 year ago

      The user can toggle their operating system’s setting. During development, the developer can do it in their browser’s dev tools.

  • Asudox@lemmy.worldM
    link
    fedilink
    arrow-up
    4
    arrow-down
    9
    ·
    1 year ago

    Locking as this post violates rule 5.

  • Mister Neon@lemmy.world
    link
    fedilink
    arrow-up
    1
    arrow-down
    8
    ·
    1 year ago

    Just use JavaScript.

Ask Lemmy@lemmy.world

asklemmy@lemmy.world

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: !asklemmy@lemmy.world

A Fediverse community for open-ended, thought provoking questions


Rules: (interactive)


1) Be nice and; have fun

Doxxing, trolling, sealioning, racism, and toxicity are not welcomed in AskLemmy. Remember what your mother said: if you can’t say something nice, don’t say anything at all. In addition, the site-wide Lemmy.world terms of service also apply here. Please familiarize yourself with them


2) All posts must end with a '?'

This is sort of like Jeopardy. Please phrase all post titles in the form of a proper question ending with ?


3) No spam

Please do not flood the community with nonsense. Actual suspected spammers will be banned on site. No astroturfing.


4) NSFW is okay, within reason

Just remember to tag posts with either a content warning or a [NSFW] tag. Overtly sexual posts are not allowed, please direct them to either !asklemmyafterdark@lemmy.world or !asklemmynsfw@lemmynsfw.com. NSFW comments should be restricted to posts tagged [NSFW].


5) This is not a support community.

It is not a place for ‘how do I?’, type questions. If you have any questions regarding the site itself or would like to report a community, please direct them to Lemmy.world Support or email info@lemmy.world. For other questions check our partnered communities list, or use the search function.


Reminder: The terms of service apply here too.

Partnered Communities:

Tech Support

No Stupid Questions

You Should Know

Reddit

Jokes

Ask Ouija


Logo design credit goes to: tubbadu


Visibility: Public
globe

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

  • 1.05K users / day
  • 2.59K users / week
  • 4.91K users / month
  • 2.01K users / 6 months
  • 0 local subscribers
  • 23.9K subscribers
  • 219 Posts
  • 4.38K Comments
  • Modlog
  • mods:
  • Bluetreefrog@lemmy.world
  • candyman337@lemmy.world
  • TheSaneWriter@lemm.ee
  • TheSaneWriter@lemmy.thesanewriter.com
  • candyman337@sh.itjust.works
  • Asudox@lemmy.world
  • can@sh.itjust.works
  • can@lemmy.ca
  • Lemmy Mod Bot@lemmy.world
  • BE: 0.19.10
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org