October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
accessibility

How to Create a Black Screen Web Page with HTML and CSS

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set the page background on the body element with CSS. This complete file creates a black, full-viewport page without JavaScript, images or a framework:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Black screen</title>
  <style>
    body {
      margin: 0;
      min-height: 100vh;
      background-color: #000;
    }
  </style>
</head>
<body>
</body>
</html>

Save it as index.html and open it in a browser. The screen will be black. MDN defines background-color as the property that sets an element box’s background color.

What each line does

  • <!doctype html> enables standards mode.
  • lang="en" identifies the document language for browsers and assistive technology; change it to your page’s language when appropriate.
  • The character-set declaration prevents common text-encoding problems.
  • The viewport meta tag tells mobile browsers to use the device’s intended layout width. Without it, some mobile browsers may use a fixed initial containing-block width, commonly 980 CSS pixels, and scale the page down.
  • margin: 0 removes the browser’s default body margin.
  • min-height: 100vh makes the body at least as tall as the viewport. vh is a viewport-height unit.
  • background-color: #000 applies black. #000, #000000 and the named color black represent the same basic black.

An empty body is valid when the purpose is simply a black screen. You do not need JavaScript, a background image, a gradient or a CSS framework.

Build the page step by step

  1. Create the file

    Make a new folder, create index.html, and paste the complete example into it. Ensure your editor does not save it as index.html.txt.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    #1 Best Overall
    Magicmoon 2-Pack 24 Inch Computer Privacy Screen Filter for 16:9 Monitor
    • Compatible Model(s): Magicmoon brand filter only for 24 inch -diagonally measured - widescreen monitor - aspect ratio 16:9 - filter size: width: 20 15/16", Height: 11 13/16" (531mm x 298mm)
    • Superior Privacy: The computer privacy filter makes the screen appear dark when looking at it from an angle (the angle is about 30 to 60 degree), but bright when looking directly at it. To change the privacy level - simply adjust your monitor’s brightness accordingly
    • Eye and Screen Protection: Privacy Filter does not only protect your private life but also protects your eyes by blocking 30% of blue light , blocking the harmful blue light between 380 to 495 nm, it filters out the blue light and relieves eye strain
    • Perfect For Open Workspaces: Great for maintaining screen privacy in open work spaces
    • Includes Two Options: Option 1 uses clear adhesive strips that securely attach to any computer screen. Option 2 (for computer screens with a raised bezel only) uses slide mount tabs that easily stick to the display frame, allowing you to slide the privacy screen filter on and off as needed
  2. Open it locally

    Double-click the file or choose Open File in your browser. A local file:// URL is sufficient for this static page.

  3. Check the viewport

    Resize the browser window and inspect the page on a phone or responsive-device emulation. The black background should reach every edge, with no white strip from the body’s default margin.

  4. Publish when ready

    Upload index.html to any static web host if you need a public URL. Hosting is not required to test the HTML.

Choose the right black

Pure black

Use #000 for the darkest possible RGB value. It is useful for a deliberately blank screen, a stage backdrop or a design whose contrast is built around black.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Near-black surfaces

For an interface, a near-black such as #111 or #121212 can create visual separation between panels. These are design choices, not replacements required by CSS; use the exact color your visual specification calls for.

Rank #2
[2 Pack] 24 Inch Computer Privacy Screen Filter for 16:9 Widescreen Monitor
  • 【24 PRIVACY FILTER DIMENSIONS】 Width: 20 15/16" (20.9 inches/532 mm), Height: 11 13/16" (11.8 inches/299 mm) - 16:9 Aspect Ratio. Mamol computer privacy filters are designed to be perfectly compatible with HP, Samsung, Dell, Lenovo, Acer, Asus, LG, ViewSonic and other brands of monitors. Please check the width and height dimensions of your computer screen before ordering. If you have any questions about the dimensions, please contact us.
  • 【ENHANCED PRIVACY PROTECTION】Mamol 24 inch computer privacy filter keeps your electronic information confidential, making it excellent for use in high traffic areas. the computer privacy screen 24 inch is designed with advanced microlouver technology to block visibility at around 30 degrees and black out screens completely near 60 degrees.
  • 【EYES PROTECTION】 This blackout privacy screen greatly reduces eye strain and minimizes potential hazards to vision. It filters 99.9% of UV rays and suppresses 98% of blue light. As a reversible 24-inch privacy screen filter: The glossy side of the protector provides extra clarity and greater privacy, and the matte side minimizes glare and distracting reflections. Satisfy your different daily uses as needed.
  • 【BETTER HD CLARTIY】Mamol 24 inch computer privacy screen Shield adds an extra layer of AR Ultra HD light transmission compared to others. It maintains the high definition of the screen without sacrificing too much screen brightness. It won't reduce the brightness and cause eye fatigue because of the privacy screen installed on the screen.
  • 【ANTI SCRATCH & WASHABLE 】Our privacy anti-glare Monitor film has a surface enhancement layer to protect the privacy filter from scratches and fingerprints. It is washable and reusable. Even after prolonged use, you will get a brand new privacy screen for your desktop computer monitor after cleaning. Very Durable!

Black with a foreground element

Add content inside the body while keeping the background rule:

<body>
  <main class="screen">
    <h1>Night mode</h1>
    <p>This text sits on a black background.</p>
  </main>
</body>
body {
  margin: 0;
  min-height: 100vh;
  background-color: #000;
  color: #fff;
  font-family: system-ui, sans-serif;
}
.screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  padding: 2rem;
  box-sizing: border-box;
}

Text changes the accessibility requirements. A black background itself has no text to read, but every heading, paragraph, icon or control placed on it needs sufficient contrast and a usable focus state.

Fixed black versus a theme-aware page

Use a fixed black page when black is the requirement

The unconditional background-color: #000 rule is predictable. It does not change when the visitor’s operating system requests a light theme, so it is the correct choice for a black-screen utility, a visual effect or a design specification that explicitly requires black.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use prefers-color-scheme when the page should adapt

MDN’s prefers-color-scheme media feature detects whether the user has requested a light or dark theme. Define both foreground and background colors so neither preference produces unreadable content:

:root {
  color-scheme: light dark;
}
body {
  margin: 0;
  min-height: 100vh;
  background: #fff;
  color: #111;
}
@media (prefers-color-scheme: dark) {
  body {
    background: #000;
    color: #fff;
  }
}

This version is not a permanently black page: it follows the visitor’s requested scheme. Keep the first, fixed rule when the title or product requires black in every situation.

Rank #3
Peslv 2-Pack 24 Inch 16:9 Computer Monitor Privacy Screen, WxH:532 * 299mm
  • 【PRIVACY FILTER DIMENSIONS】- Width: 20 15/16" (532 mm), Height: 11 13/16" (299 mm), Diagonal: 24" (609.6 mm) - Peslv Dark 24 inch Privacy Screen Filter is engineered to be compatible with 24in Dell, HP, Samsung, Lenovo, LG, Acer, ASUS, Toshiba, ViewSonic, Aoc, Sceptre, PHILIPS, ViewSonic and other brands monitors with 16:9 aspect ratio. Please verify your computer screen's width and height measurements before ordering. It is not recommended to select a size based solely on the diagonal.
  • 【HIGH-CLASS PRIVACY ABLE】Peslv collected suggestions from more than 2000 computer users and performed 22188 anti-peep angle corrections on the micro-blind optical technology to ensure that any line of sight beyond +-30° facing the screen will be shielded. With a Peslv computer privacy screen 24 inch, Protect the privacy of your computer monitor screen and no longer leak any confidential data.
  • 【2 MOUNTING OPTIONS FOR EASY INSTALLATION】The Peslv 24 inch privacy screen for monitor supply 2 installation options, Various installation options, are Compatible with both 24" computer monitors with raised bezels and full-screen 24" computer monitors without raised bezels, and convenient installation allows you to complete the installation in 9 seconds. NOTE: Monitors without raised bezels are only available with mounting option 2.
  • 【EXCLUSIVE DOUBLE-SIDED TECHNOLOGY】24-inch monitor privacy filter has a double-sided surface technology developed by Peslv. Matte or Glossy. With the matte surface facing outward, you can experience the advanced AG anti-glare technology from Germany while maintaining a 30-degree privacy angle, softening the strong light outdoors, and making the screen content clearly visible. With the glossy side facing outward, you can get a super anti-peeping effect with a privacy angle of 26 degrees.
  • 【PROTECT SCREEN ALSO EYES】Filtering optical materials imported from Japan can reduce 92% of blue light and 98% of UV light, and filter all harmful light emitted from the screen to protect your eyes. The high-transparent and reinforced built-in protective layer not only presents high-definition picture quality but also protects your screen from scratches. Hurry up and place an order, own a privacy screen for a computer monitor 24 inch, and protect your monitor screen and your eyes.

Accessibility when you add text

WCAG 2.2 Success Criterion 1.4.3 specifies a minimum contrast ratio of 4.5:1 for ordinary text and 3:1 for large-scale text at Level AA, with exceptions for incidental text and logotypes. These are WCAG thresholds, not a statement that every project or jurisdiction is legally required to conform. Read the criterion in the W3C WCAG 2.2 specification.

  • White text on pure black has strong contrast, but still check your actual font weight, size and anti-aliasing.
  • Do not communicate information with color alone; provide text, icons with accessible names or other cues.
  • Give links and buttons a visible focus indicator. A black page can hide a default dark focus outline.
  • Preserve readable line length and spacing instead of treating high contrast as a substitute for legibility.
  • If the page is intentionally empty, a meaningful document title can still identify it in a browser tab. If there is no user-facing information, there may be no additional assistive-technology content to announce.

Useful variations

Cover the viewport without forcing a fixed height

min-height: 100vh lets the page grow when content is taller than the viewport. Avoid height: 100vh for content-heavy screens unless you deliberately want clipping or scrolling behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the root element for a component or app shell

For a single-page application, you can style the mount point as well:

html, body, #app {
  margin: 0;
  min-height: 100%;
}
body, #app {
  background-color: #000;
}

If the root background is transparent, the body’s background normally paints through to the canvas. Applying the color to the element that owns your layout makes the intent clearer for component boundaries.

Make a black panel rather than a black page

.panel {
  background-color: #000;
  color: #fff;
  padding: 1.5rem;
  border-radius: .5rem;
}

Use this when only one card, modal or section should be black. Do not apply the rule to body if the rest of the document needs a different background.

Rank #4
SightPro 24 Inch 16:9 Computer Privacy Screen Filter for Monitor - Privacy Shield and Anti-Glare Protector
  • 【Privacy Filter Dimensions】- Width: 20 15/16" (532 mm), Height: 11 13/16" (299 mm), Diagonal: 24" (609.6 mm) - SightPro Blackout Privacy Screen Filter is engineered to be compatible with HP, Dell, Samsung, Lenovo, LG, Acer, ASUS, ViewSonic, and other monitor brands. Please verify your computer screen's width and height measurements before ordering. It's not recommended to make your selection based solely on your computer screen's diagonal size.
  • 【Two Attachment Options】- Installs in minutes. Option 1 uses clear adhesive strips that securely attach to any computer screen. Option 2 (for computer screens with a raised bezel only) uses slide mount tabs that easily stick to the display frame, allowing you to slide the privacy screen filter on and off as needed.
  • 【Superior Privacy and Anti Glare】- Our advanced multi-layered film filter blacks out your computer screen when viewing from the side, while maintaining a crystal clear screen straight-on. It also protects your eyes from harmful glare, UV, and blue light. [Note: It does not block visibility directly behind you, regardless of the distance.]
  • 【Perfect for Travel and Open Workspaces】- Our computer screen privacy filter is the ideal solution for healthcare providers, mobile workers, commuters, students, and business travelers. Now you can stay compliant and safeguard sensitive corporate information while working in airplanes, subways, airports and public areas.
  • 【Package Contents】- Each package includes one privacy screen shield filter, two sets of clear adhesive strips, two sets of slide mount tabs, and a microfiber cleaning cloth. Buy with confidence – located in the US, Sight Pro specializes in providing best-in-class privacy solutions to individuals, small businesses, corporations, government, and educational institutions. Our privacy screens are Section 889 and TAA compliant.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

The page is white

  • Confirm the file ends in .html and that the browser opened the file you edited.
  • Open developer tools and inspect body. A later, more-specific rule or an inline style may override the background.
  • Check for a syntax error such as a missing brace or semicolon. The minimal declaration is body { background-color: #000; }.
  • If a child element covers the entire viewport with its own background, style that element or remove its background.

A white border appears around the screen

Set margin: 0 on body. User-agent styles commonly add a default margin.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The black area stops before the bottom

Use min-height: 100vh on the body. If a parent layout controls the height, also inspect that parent and any root application container.

Mobile content looks tiny

Add the viewport declaration shown in the complete example. It prevents the fixed-width initial layout behavior described in MDN’s viewport guide.

Text is difficult to read

Measure the actual foreground/background pair and meet the WCAG contrast target appropriate to your text size. Increase font size or weight, change the foreground color, and test keyboard focus states.

The page is black in one browser but not another

Check whether you are testing a fixed rule or a prefers-color-scheme rule, then inspect computed styles in both browsers. Remove competing stylesheets and verify that the CSS file is loading with a successful network response.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Computer Privacy Screen Filter for 24 Inch 16:9 Aspect Ratio Monitor
  • Privacy Screen Filter Size: If the visible area of your display has the following dimension: Width x Height (Exclude Frame/Arrow 1 to 3 mm errors): 20 15/16" x 11 13/16" (532 mm x 299 mm), then this filter is good for you. Very Important to double check your screen's Width and Height excluding frame before ordering. It's not recommended to make your selection based solely on your screen's diagonal size
  • Left and Right Privacy: Not block visibility directly behind you, regardless of distance. The privacy filter makes the screen appear dark when looking at it from an angle (left and right 30 to 180 degree), but clear when looking directly at it. To change the privacy levels, simply adjust your monitor's brightness level accordingly
  • Matte and Glossy Sides: It's a reversible privacy screen filter, giving you the flexibility to choose glossy or matte finish. The matte side will have less glare, however the glossy side will have stronger privacy
  • Perfect for Open Workspaces: Ensure your working space is bright and well lit. Privacy screens do not work in dimly lit areas
  • Two Installation Option: Option 1 uses clear double side adhesive strips that securely attach to any computer screen. Option 2 (for computer screens with a raised bezel only) uses slide mount tabs that easily stick to the display frame, allowing you to take out the privacy screen filter easily as needed

Verify before publishing

  • Load the file with JavaScript disabled; the black background should still work.
  • Test a narrow phone viewport, a wide desktop viewport and a zoomed page.
  • Inspect the page at the browser’s default zoom and at 200% if it contains text.
  • Use keyboard navigation to confirm that links and controls remain visible against black.
  • Run an accessibility checker, then manually verify contrast and focus because automated tools cannot judge every design decision.
  • Clear the browser cache or use a hard reload after changing an external stylesheet.

Or skip the browser setup

If you need an image or PDF of the finished black page rather than a local browser check, ScreenshotNeo can capture a URL with one request. Its cleanup step accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; you can turn those steps off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

For a public page such as https://example.com/black-screen.html, the cURL request is:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/black-screen.html -o shot.webp

See the ScreenshotNeo documentation for authentication, output formats and capture options. The equivalent Python request is:

import requests
r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.com/black-screen.html"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({
  access_key: 'YOUR_API_KEY',
  url: 'https://example.com/black-screen.html'
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

ScreenshotNeo also supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper size/margins/orientation/page ranges, custom CSS and JavaScript, pre-capture clicks, hidden selectors, waits for a selector, delay or network idle, blocking ads/trackers/requests/resource types, custom headers/cookies/user agents/Authorization, timezone and geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to try the capture without adding a card.

Frequently Asked Questions

Can I create the black screen with only HTML?

HTML provides the document structure, but CSS supplies the background color. Put the CSS in a style element, an external stylesheet or an inline style.

Is #000 different from black?

For the basic CSS color value, both render pure black. Use whichever notation matches your project’s style conventions.

Do I need JavaScript for a black background?

No. The background is rendered by CSS, so the minimal page works with JavaScript disabled.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do I make only one section black?

Apply background-color: #000 to that section or a class such as .panel instead of styling body.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.