Skip to content

Commit e7c97b0

Browse files
dipreehubwriter
andauthored
Update theme context docs (#27909)
* Update theme context docs * Update example description * Update content/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md * Update content/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md * Update content/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md Co-authored-by: hubwriter <[email protected]>
1 parent 3604732 commit e7c97b0

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

content/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,19 @@ For more information, see "[Relative Links](#relative-links)."
148148
{% ifversion fpt or ghec or ghes > 3.3 or ghae-issue-5559 %}
149149
### Specifying the theme an image is shown to
150150

151-
You can specify the theme an image is displayed to by appending `#gh-dark-mode-only` or `#gh-light-mode-only` to the end of an image URL, in Markdown.
151+
You can specify the theme an image is displayed for in Markdown by using the HTML `<picture>` element in combination with the `prefers-color-scheme` media feature. We distinguish between light and dark color modes, so there are two options available. You can use these options to display images optimized for dark or light backgrounds. This is particularly helpful for transparent PNG images.
152152

153-
We distinguish between light and dark color modes, so there are two options available. You can use these options to display images optimized for dark or light backgrounds. This is particularly helpful for transparent PNG images.
153+
For example, the following code displays a sun image for light themes and a moon for dark themes:
154154

155-
| Context | URL |
156-
|--------|--------|
157-
| Dark Theme | `![GitHub Light](https://github.com/github-light.png#gh-dark-mode-only)` |
158-
| Light Theme | `![GitHub Dark](https://github.com/github-dark.png#gh-light-mode-only)` |
155+
```HTML
156+
<picture>
157+
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/25423296/163456776-7f95b81a-f1ed-45f7-b7ab-8fa810d529fa.png">
158+
<source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/25423296/163456779-a8556205-d0a5-45e2-ac17-42d089e3c3f8.png">
159+
<img alt="Shows an illustrated sun in light color mode and a moon with stars in dark color mode." src="https://user-images.githubusercontent.com/25423296/163456779-a8556205-d0a5-45e2-ac17-42d089e3c3f8.png">
160+
</picture>
161+
```
162+
163+
The old method of specifying images based on the theme, by using a fragment appended to the URL (`#gh-dark-mode-only` or `#gh-light-mode-only`), is deprecated and will be removed in favor of the new method described above.
159164
{% endif %}
160165

161166
## Lists

0 commit comments

Comments
 (0)