To make a web page display a plain black screen, set the page body’s background-color to #000, remove its default margin, and give it at least the height of the viewport. You do not need JavaScript, an image, or a framework. The complete file below works as a simple starting point.
Make a black screen with one HTML file
Create a new file named index.html in a text editor and paste in this complete example:
<!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 the file with the
.htmlextension, not.txt. - Open the saved file in a browser. The page area should appear black.
- If you change the CSS, save the file and reload the browser tab to see the update.
The key declaration is background-color: #000;. It assigns a black background to the body element. MDN defines background-color as the property that “sets the background color of an element box.” See the MDN background-color reference.
What each part does
<!doctype html>tells the browser to parse the document as HTML.<meta charset="utf-8">sets the document’s character encoding.<meta name="viewport" content="width=device-width, initial-scale=1">gives mobile browsers a viewport width based on the device display and an initial scale of 1. Without a viewport declaration, some mobile browsers may lay out a page using a fixed initial containing-block width (typically 980 CSS pixels) and scale it down. MDN explains this behavior in its CSS viewport guide.margin: 0;removes the body’s default outer margin, so a strip of the browser’s canvas color does not show around the page.min-height: 100vh;makes the body at least as tall as the viewport. It is a minimum rather than a fixed height, so the page can still grow if you later add content.background-color: #000;sets the body’s background to black.
Choose the right black background declaration
All three of these CSS values represent black: #000, #000000, and the named color black. The three-digit hexadecimal value is the concise option used in the example. Use whichever form best matches the conventions of your stylesheet; the important part is applying it to the element that should have the background.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- 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
For a plain page, styling body is a straightforward choice. CSS background behavior has a special case: if the root element (html) has its initial transparent background and no background image, the body background can be propagated to the canvas. MDN describes this in its background documentation. If you are building a more complex layout or setting a background on several containers, be deliberate about which element owns the color rather than assuming every child inherits it.
When to use the root element instead
If you want the document canvas itself to have an explicit background, you can style html as well as body:
html,
body {
margin: 0;
min-height: 100%;
background-color: #000;
}
This is not required for the simple empty page shown above. Avoid adding extra declarations without a reason: start with the body rule, then add root styling if your page structure or other styles make it necessary.
Rank #2
- 【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!
Make the page fixed black or theme-aware
A fixed black screen and a page that changes with the visitor’s light or dark preference are different design choices. The title’s simplest interpretation is fixed black, so the example sets that color unconditionally. If the page is a regular interface rather than an intentionally black screen, CSS can instead detect a requested color theme with prefers-color-scheme. MDN describes the media feature in its prefers-color-scheme reference.
For a theme-aware page, define both background and text colors for each theme. For example:
:root {
color-scheme: light;
background-color: #fff;
color: #111;
}
@media (prefers-color-scheme: dark) {
:root {
color-scheme: dark;
background-color: #000;
color: #fff;
}
}
This sample is an alternative, not an addition to the fixed-black example: remove or replace the unconditional black body rule if you want the page to follow the preference. A theme-aware page should still be checked in both modes, including any links, form controls, borders, and focus indicators you add. Do not assume that changing the background alone makes the whole interface readable.
Rank #3
- 【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.
Add content without losing readability
An empty black page has no text contrast problem because it contains no text. If you add a heading, instructions, a button, or other text, choose a foreground color that remains legible against black. Under WCAG 2.2 Success Criterion 1.4.3 at Level AA, ordinary text requires a contrast ratio of at least 4.5:1, while large-scale text requires at least 3:1. The criterion includes exceptions, including incidental text and logotypes; these are thresholds in the standard, not a claim that every project or jurisdiction is legally required to conform. See the W3C WCAG 2.2 standard.
White is a common foreground choice on a black background, but do not rely on a color name or visual impression alone when the page has more complex colors or small text. Check the actual text and background colors with a contrast evaluation tool, and consider the text size and weight. Also provide information through words or structure, not color alone.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteA blank document can serve as a visual screen, but it does not communicate information to a screen reader. If the page is meant to tell visitors something, include meaningful HTML content. For example, put a useful heading or status message in the body and style it; do not make essential instructions available only as pixels in an image or as a visual effect.
Rank #4
- 【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.
Check and troubleshoot the result
- The page is white. Confirm that the
background-colorrule is inside a valid<style>element in the document’s<head>, or in a stylesheet that the page actually loads. Check for a later CSS rule overriding the body background. - A white border appears around the black area. Make sure
margin: 0;applies tobody. A browser’s default body margin can leave a visible edge. - The page is black only behind some content. Another element may have its own background color covering the body. Remove that background or set the relevant container to transparent if the design calls for the black to show through.
- The file opens as text or downloads instead of displaying a page. Check that it is actually named with the
.htmlextension. Some editors append.txtautomatically. - The mobile layout looks zoomed out. Keep the viewport meta tag in the head and confirm it has the exact
name="viewport"andcontent="width=device-width, initial-scale=1"values. - Changes do not appear after editing. Save the HTML file, reload the tab, and verify that you edited the same file the browser has open. If you use a separate CSS file, check the stylesheet link’s path and filename.
- Only part of the browser window is black. A web page can color its document area, but it cannot use ordinary page CSS to recolor browser interface such as tabs, address bar, or operating-system controls. Those areas are managed by the browser or system.
Or skip the browser setup
If your page is already available at a URL and you need an image of how it renders, ScreenshotNeo can return a screenshot from one GET request; it does not create or host the HTML page. Its options include PNG, JPEG, WebP, or PDF output. The ScreenshotNeo website describes the service, and the API documentation covers the request parameters.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://your-site.example/black-screen -o shot.webp
Replace the example URL with the public URL of your page and YOUR_API_KEY with your key. The file is saved as shot.webp; change the output filename or request format if you want another supported image format. The request can capture a page only after that page is available at the URL you provide.
- Cookie and consent banners are accepted like a visitor, and more than 60 known consent platforms, newsletter popups, and chat widgets can be removed before the shot; each step can be turned off.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. Response headers identify the page verdict and billing status.
- An MCP server provides
take_screenshot,get_page_info, andcapture_pdftools for AI agents, including Claude, Cursor, and other MCP clients. - The Free plan includes 1,000 screenshots per month with no card required. Paid plans start at $5 for 3,000 screenshots; yearly billing gives two months free. Every feature is on every plan.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Best Value
- 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
Publish the page only if you need a public URL
Opening index.html locally is enough to view the effect on your own device. If you want other people or a screenshot service to access it, the file must be served from a URL they can reach. The specific publishing steps depend on the hosting service, and hosting is not needed to create the black page itself. Once deployed, visit the page URL and check it at desktop and mobile viewport sizes.
For a one-screen page, keeping the document small and using CSS rather than an image avoids an unnecessary asset and keeps the background sharp at different display sizes. If you later add content or interactive controls, test the actual rendered page again: new elements, styles, or scripts can change what is visible and whether the content is accessible.
Frequently Asked Questions
Can I put the CSS in a separate file instead of inside the HTML?
Yes. Move the CSS rules into a file such as styles.css and add <link rel="stylesheet" href="styles.css"> inside the document’s <head>. Keep the file path accurate relative to the HTML file.
Will this change the color of the browser’s address bar or tabs?
No. The CSS styles the web page’s document area. Browser chrome and operating-system interface are controlled outside the page.
Quick Recap
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.

