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 5, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 5, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 5, 2025

      In MCP era API discoverability is now more important than ever

      June 5, 2025

      Google’s DeepMind CEO lists 2 AGI existential risks to society keeping him up at night — but claims “today’s AI systems” don’t warrant a pause on development

      June 5, 2025

      Anthropic researchers say next-generation AI models will reduce humans to “meat robots” in a spectrum of crazy futures

      June 5, 2025

      Xbox just quietly added two of the best RPGs of all time to Game Pass

      June 5, 2025

      7 reasons The Division 2 is a game you should be playing in 2025

      June 5, 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

      Mastering TypeScript: How Complex Should Your Types Be?

      June 5, 2025
      Recent

      Mastering TypeScript: How Complex Should Your Types Be?

      June 5, 2025

      IDMC – CDI Best Practices

      June 5, 2025

      PWC-IDMC Migration Gaps

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

      Google’s DeepMind CEO lists 2 AGI existential risks to society keeping him up at night — but claims “today’s AI systems” don’t warrant a pause on development

      June 5, 2025
      Recent

      Google’s DeepMind CEO lists 2 AGI existential risks to society keeping him up at night — but claims “today’s AI systems” don’t warrant a pause on development

      June 5, 2025

      Anthropic researchers say next-generation AI models will reduce humans to “meat robots” in a spectrum of crazy futures

      June 5, 2025

      Xbox just quietly added two of the best RPGs of all time to Game Pass

      June 5, 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

    Google’s DeepMind CEO lists 2 AGI existential risks to society keeping him up at night — but claims “today’s AI systems” don’t warrant a pause on development

    June 5, 2025
    News & Updates

    Anthropic researchers say next-generation AI models will reduce humans to “meat robots” in a spectrum of crazy futures

    June 5, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    CVE-2025-45427 – Tenda AC9 Stack Overflow Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2022-21200 – Apache HTTP Server Cross-Site Scripting

    Common Vulnerabilities and Exposures (CVEs)

    New Techniques, Same Threat: APT40 Adapts Tactics for Broader Attacks

    Development

    Schools will remove app from students’ Chromebooks and iPads following security breach

    Development

    Highlights

    Windows 11 is planning a huge redesign of its Start Menu

    April 7, 2025

    Microsoft plans to redesign the Windows 11 Start menu with a refreshed layout and enhanced…

    Development Release: AlmaLinux OS 9.6 Beta

    April 29, 2025

    Laravel Cookie Consent

    April 16, 2025

    What are Instant Links and How to Enable Them in Arc Browser

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

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