A small piece of HTML can change what a visitor sees or how the browser understands a page. In this lesson, you will explore color scheme hints and native ui using a short example that you can inspect and change.
The Idea in Plain English
The color-scheme metadata hints which light or dark built-in browser styles a document supports. CSS still controls the actual application design.
You can test this using a small local HTML file. Change one part at a time and check the result in the browser before adding more code.
A Working Example
Read the sample once before copying it. Notice the element names and attribute values, then compare them with the explanation below.
<head>
<meta name="color-scheme" content="light dark">
<style>
body { color-scheme: light dark; }
</style>
</head>
What Each Part Does
- The meta element supplies machine-readable settings; its name or charset decides which setting.
- The style element contains CSS rather than ordinary HTML body text.
- The head holds page metadata, not the visible lesson content.
- name identifies a field in submitted form data or a named metadata entry.
- content supplies the value of a meta declaration.
Form controls and scrollbars may use light or dark appearances where supported.
Keep the example small while learning. Once it behaves as expected, try it inside a larger page and make sure the URLs, files and surrounding HTML are correct.
Try It Yourself
Try this next: create one complete head or structured content example focused on Color Scheme Hints and Native UI, including a working example and an incorrect example to correct. Then inspect the page and explain what changed.
Common Beginner Mistakes
- Declaring dark mode support while leaving black text on a dark background.
- Changing several parts of the example at once, making it difficult to see which part caused a different result.
- Choosing a tag only because its default appearance looks right, without checking whether it describes the content correctly.
Key Takeaways
- The color-scheme metadata hints which light or dark built-in browser styles a document supports. CSS still controls the actual application design.
- Form controls and scrollbars may use light or dark appearances where supported.
- Test the markup in a browser, and check accessibility and real-world behavior where relevant.