Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 4, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 4, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 4, 2025

      Smashing Animations Part 4: Optimising SVGs

      June 4, 2025

      I test AI tools for a living. Here are 3 image generators I actually use and how

      June 4, 2025

      The world’s smallest 65W USB-C charger is my latest travel essential

      June 4, 2025

      This Spotlight alternative for Mac is my secret weapon for AI-powered search

      June 4, 2025

      Tech prophet Mary Meeker just dropped a massive report on AI trends – here’s your TL;DR

      June 4, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Beyond AEM: How Adobe Sensei Powers the Full Enterprise Experience

      June 4, 2025
      Recent

      Beyond AEM: How Adobe Sensei Powers the Full Enterprise Experience

      June 4, 2025

      Simplify Negative Relation Queries with Laravel’s whereDoesntHaveRelation Methods

      June 4, 2025

      Cast Model Properties to a Uri Instance in 12.17

      June 4, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      My Favorite Obsidian Plugins and Their Hidden Settings

      June 4, 2025
      Recent

      My Favorite Obsidian Plugins and Their Hidden Settings

      June 4, 2025

      Rilasciata /e/OS 3.0: Nuova Vita per Android Senza Google, Più Privacy e Controllo per l’Utente

      June 4, 2025

      Rilasciata Oracle Linux 9.6: Scopri le Novità e i Miglioramenti nella Sicurezza e nelle Prestazioni

      June 4, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»How to make your images in Markdown on GitHub adjust for dark mode and light mode

    How to make your images in Markdown on GitHub adjust for dark mode and light mode

    April 18, 2025

    GitHub supports dark mode and light mode, and as developers, we can make our README images look great in both themes. Here’s a quick guide to using the <picture> element in your GitHub Markdown files to dynamically switch images based on the user’s color scheme.

    When developers switch to GitHub’s dark mode (or vice versa), standard images can look out of place, with bright backgrounds or clashing colors.

    Instead of forcing a one-size-fits-all image, you can tailor your visuals to blend seamlessly with the theme. It’s a small change, but it can make your project look much more polished.

    One snippet, two themes!

    Here’s the magic snippet you can copy into your README (or any Markdown file):

    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="dark-mode-image.png">
      <source media="(prefers-color-scheme: light)" srcset="light-mode-image.png">
      <img alt="Fallback image description" src="default-image.png">
    </picture>
    

    Now, we say it’s magic, but let’s take a peek behind the curtain to show how it works:

    • The <picture> tag lets you define multiple image sources for different scenarios.
    • The <source media="..."> attribute matches the user’s color scheme.
      • When media="(prefers-color-scheme: dark)", the browser loads the srcset image when GitHub is in dark mode.
      • Similarly, when media="(prefers-color-scheme: light)", the browser loads the srcset image when GitHub is in light mode.
    • If the browser doesn’t support the <picture> element, or the user’s system doesn’t match any defined media queries, the fallback <img> tag will be used.

    You can use this approach in your repo README files, documentation hosted on GitHub, and any other Markdown files rendered on GitHub.com!

    Demo

    What’s better than a demo to help you get started? Here’s what this looks like in practice:


    https://github.blog/wp-content/uploads/2025/04/Toggle-Dark-and-Light-Mode-on-GitHub-.mp4#t=0.001

    The post How to make your images in Markdown on GitHub adjust for dark mode and light mode appeared first on The GitHub Blog.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleImprove ImgSLI is an image comparison tool
    Next Article GoldenDict-ng is an advanced dictionary lookup program

    Related Posts

    News & Updates

    I test AI tools for a living. Here are 3 image generators I actually use and how

    June 4, 2025
    News & Updates

    The world’s smallest 65W USB-C charger is my latest travel essential

    June 4, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    DAI#43 – AI Apples, search power, and Meta’s EU ‘pretty please’

    Artificial Intelligence

    Maxicare Confirms Data Breach in Third-Party Booking Platform, Ensures Core Systems Unaffected

    Development

    The best 98-inch TVs of 2025: Expert tested

    News & Updates

    SolarWinds Releases Patch for Critical Flaw in Web Help Desk Software

    Development

    Highlights

    CLI Experiments : Intro + Big Text

    July 1, 2024

    Let’s lay a foundation for building TUIs with Laravel Prompts. We’ll explore the structure of…

    Sinkclose Vulnerability in AMD Chips: What You Need to Know About Unpatched Models

    August 12, 2024

    CVE-2023-53134 – “Broadcom bnxt_en Linux kernel Memory Allocation Vulnerability”

    May 2, 2025

    API with NestJS #154. Many-to-many relationships with Drizzle ORM and PostgreSQL

    June 24, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.