For a standard crosshair, CSS alone is enough: apply cursor: crosshair to the area where it should appear. If you want a custom graphic that follows the pointer or trails behind it, add a decorative HTML element and position it with JavaScript. The custom element should remain a visual layer, not interfere with the page’s links, buttons, or other controls.
Choose the right kind of crosshair
There are two practical approaches. Use the browser’s native crosshair for a simple, dependable pointer on a particular region. Use a custom cursor image or a JavaScript-positioned overlay when you need a distinct shape, a follow effect, or animation.
As an Amazon Associate I earn from qualifying purchases.
| Approach | Best for | Tradeoff |
|---|---|---|
CSS cursor: crosshair |
A standard crosshair in a particular region | Its appearance and behavior are browser-provided. MDN’s cursor reference lists it as a predefined keyword. |
| CSS cursor image | A custom cursor graphic without a separate tracking element | Requires a fallback keyword; image dimensions and hotspot behavior can vary by browser. MDN documents the cursor image syntax and limits. |
| JavaScript-positioned overlay | A shape that follows, trails, or animates with the pointer | Needs pointer tracking, hit-testing safeguards, fallback behavior, and care with motion preferences and devices. |
Use the native CSS crosshair
Apply the cursor to only the region where it makes sense, rather than changing it indiscriminately across the page. For example:
Recommended Free Tools
.drawing-area {
cursor: crosshair;
}
MDN notes that a cursor should communicate the mouse operation available at the current location, such as selecting text, activating a control, or resizing content. Keep the usual cursor on text, links, and buttons when a crosshair would mislead users.
#1 Best Overall
- The next-generation optical HERO sensor delivers incredible performance and up to 10x the power efficiency over previous generations, with 400 IPS precision and up to 12,000 DPI sensitivity
- Ultra-fast LIGHTSPEED wireless technology gives you a lag-free gaming experience, delivering incredible responsiveness and reliability with 1 ms report rate for competition-level performance
- G305 wireless mouse boasts an incredible 250 hours of continuous gameplay on just 1 AA battery; switch to Endurance mode via Logitech G HUB software and extend battery life up to 9 months
- Wireless does not have to mean heavy, G305 lightweight mouse provides high maneuverability coming in at only 3.4 oz thanks to efficient lightweight mechanical design and ultra-efficient battery usage
- The durable, compact design with built-in nano receiver storage makes G305 not just a great portable desktop mouse, but also a great laptop travel companion, use with a gaming laptop and play anywhere
Use a custom cursor image
If a static custom crosshair is enough, CSS supports an image cursor with a keyword fallback. The optional numbers set the hotspot—the active point—relative to the image’s top-left corner:
.drawing-area {
cursor: url("/images/crosshair.png") 16 16, crosshair;
}
Here, 16 16 places the hotspot 16 pixels from the image’s left edge and 16 pixels from its top edge. Change those coordinates to match the point that should align with the pointer. Keep the fallback keyword after the image URL so the browser has another cursor to use if the image cannot be used.
Rank #2
- HERO Gaming Sensor: Next generation HERO mouse sensor delivers precision tracking up to 25600 DPI with zero smoothing, filtering or acceleration
- 11 programmable buttons and dual mode hyper-fast scroll wheel: The Logitech wired gaming mouse gives you fully customizable control over your gameplay
- Adjustable weights: Match your playing style. Arrange up to five 3.6 g weights for a personalized weight and balance configuration
- LIGHTSYNC technology: Logitech G LIGHTSYNC technology provides fully customizable RGB lighting that can also synchronize with your gaming (requires Logitech Gaming Software)
- Mechanical Switch Button Tensioning: A metal spring tensioning system and metal pivot hinges are built into left and right computer gaming mouse buttons for a crisp, clean click feel with rapid click feedback
Cursor image dimensions are not uniformly supported. MDN recommends 32 by 32 pixels and notes a default restriction of 128 by 128 pixels in Firefox and Chromium; these are documentation notes, not guarantees for every browser or version. See MDN’s cursor reference for details.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Build a crosshair that follows the pointer
A separate element gives you more control over the crosshair’s appearance and movement. This example creates a decorative overlay, starts it when a mouse or pen moves over the page, and leaves the system cursor available as a fallback.
Rank #3
- Next-gen 12,000 DPI HERO optical sensor delivers unrivaled gaming performance, accuracy and power efficiency
- Advanced LIGHTSPEED wireless gaming mouse for super-fast 1 ms response time and faster than wired performance
- Ultra-long battery life gives you up to 250 hours of continuous gaming on a single AA battery
- Lightweight mechanical design and classic shape for maximum maneuverability, durability and comfort
- Compact, portable design with convenient built-in storage for included USB wireless receiver
1. Add the decorative element
<div class="pointer-crosshair" aria-hidden="true"></div>
The element is hidden from assistive technology because it is decoration, not content or a control.
2. Style and position it
.pointer-crosshair {
position: fixed;
left: 0;
top: 0;
width: 24px;
height: 24px;
border: 1px solid currentColor;
border-radius: 50%;
transform: translate(-50%, -50%);
pointer-events: none;
z-index: 1000;
opacity: 0;
}
.pointer-crosshair::before,
.pointer-crosshair::after {
content: "";
position: absolute;
background: currentColor;
}
.pointer-crosshair::before {
width: 1px;
height: 8px;
left: 50%;
top: -5px;
transform: translateX(-50%);
box-shadow: 0 26px currentColor;
}
.pointer-crosshair::after {
width: 8px;
height: 1px;
top: 50%;
left: -5px;
transform: translateY(-50%);
box-shadow: 26px 0 currentColor;
}
position: fixed and viewport coordinates keep the overlay aligned with the pointer while the page scrolls. The centering transform makes its center the active point. The initial zero opacity prevents an element fixed at the top-left corner from flashing before pointer movement.
Rank #4
- ICONIC ERGONOMIC DESIGN WITH THUMB REST — PC gaming mouse favored by millions worldwide with a form factor that perfectly supports the hand while its buttons are optimally positioned for quick and easy access
- 11 PROGRAMMABLE BUTTONS — Assign macros and secondary functions across 11 programmable buttons to execute essential actions like push-to-talk, ping, and more
- HYPERSCROLL TILT WHEEL — Speed through content with a scroll wheel that free-spins until its stopped or switch to tactile mode for more precision and satisfying feedback that’s ideal for cycling through weapons or skills
- 11 RAZER CHROMA RGB LIGHTING ZONES — Customize each zone from over 16.8 million colors and countless lighting effects, all while it reacts dynamically with over 150 Chroma integrated games
- OPTICAL MOUSE SWITCHES GEN 2 — With zero unintended misclicks these switches provide crisp, responsive execution at a blistering 0.2ms actuation speed for up to 70 million clicks
3. Update it from pointer events
const crosshair = document.querySelector(".pointer-crosshair");
window.addEventListener("pointermove", (event) => {
if (event.pointerType === "touch") return;
crosshair.style.left = `${event.clientX}px`;
crosshair.style.top = `${event.clientY}px`;
crosshair.style.opacity = "1";
});
clientX and clientY are viewport coordinates, matching the fixed positioning. Pointer Events cover mouse, pen, and touch; this example skips touch because a mouse-following decoration generally has no useful role on a touch-only screen. If your design should support a different set of devices, choose the behavior deliberately rather than assuming every pointer is a mouse.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problems4. Keep the overlay from blocking interaction
The pointer-events: none rule is essential: it lets pointer events target the content underneath the crosshair instead of the decorative element. Without it, the overlay can interfere with links, buttons, and hover states. MDN explains this behavior in its pointer-events reference.
Best Value
- Pentakill, 5 DPI Levels - Geared with 5 redefinable DPI levels (default as: 500/1000/2000/3000/4000), easy to switch between different game needs. Dedicated demand of DPI options between 500-8000 is also available to be processed by software.
- Any Button is Reassignable - 11 programmable buttons are all editable with customizable tactical keybinds in whatever game or work you are engaging. 1 rapid fire + 2 side macro buttons offer you a better gaming and working experience.
- Comfort Grip with Details - The skin-friendly frosted coating is the main comfort grip of the mouse surface, which offers you the most enjoyable fingerprint-free tactility. The left side equipped with rubber texture strengthened the friction and made the mouse easier to control.
- 5 Decent Backlit Modes - Turn the backlit on and make some kills in your gaming battlefield. The hyped dynamic RGB backlit vibe will never let you down when decorating your gaming space, it would be better with other Redragon accessories with lights on.
- Fatigue Killer with Ergonomic Design - Solid frame with a streamlined and general claw-grip design offers a satisfying and comfortable gaming experience with less fatigue even though after hours of use.
Add a trailing effect without ignoring reduced motion
A follow effect can be softened with a CSS transition, but movement should respect the visitor’s system preference. One option is to enable a short transition only when reduced motion has not been requested:
@media (prefers-reduced-motion: no-preference) {
.pointer-crosshair {
transition: left 80ms linear, top 80ms linear, opacity 120ms ease;
}
}
@media (prefers-reduced-motion: reduce) {
.pointer-crosshair {
transition: none;
}
}
The prefers-reduced-motion media feature lets a site adapt movement to the visitor’s preference. For more background, see MDN’s reduced-motion reference.
Check the effect across devices and interactions
- Do not replace useful cursor meaning: keep text selection, links, buttons, and resize affordances understandable.
- Maintain contrast: choose a crosshair that remains visible over the page’s backgrounds, and avoid obscuring text or important controls.
- Keep a fallback: a native cursor or CSS fallback remains useful if the custom element or its JavaScript is unavailable.
- Account for device differences: Pointer Events include mouse, pen, and touch. On iPadOS, a pointer device uses a circular pointer by default, and MDN notes that only the
textcursor value changes its appearance by default. Do not assume desktop cursor styling will look identical there. See MDN’s cursor reference and Pointer Events documentation.
The browser-provided crosshair is the simplest choice when it meets the need. A custom overlay is appropriate when its distinct appearance or movement adds value, provided it stays decorative and does not get in the way of the interface.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteQuick 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.




