Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

95
Views
Is it possible to exclusively target touch input devices?

I made an hover effect that would work well on mouse/keyboard interfaces but not so ideally with touch interfaces. I would like to target touch interface devices with some kind of media query or something that sets the touch input devices away from desktop style devices.

I would have used the screen size media queries but there are tablets whose sizes overlap with those of laptops. Is there a way to target touch interface devices with JavaScript or pure CSS or some other way?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can do it using pointer media query:

div {
  padding: 8px;
  width: 200px;
  border: 1px solid;
}

@media (pointer:fine) {
  div:hover {
    cursor: pointer;
    background-color: red;
  }
}

@media (pointer:coarse) {
  div:active {
    background-color: green;
  }
}
<div>Hover me on PC</div>

The hover property is defined only for those devices which has mouse(fine cursor);

Or you can apply different property for touch screens using
@media (pointer:coarse)

about 4 years ago · Juan Pablo Isaza Report

0

You can sense if a device is a touch one by looking at some capabilities.

For example, the media query on hover tells you whether the device understands 'proper' hovering.

Here's a simple snippet to demonstrate:

.hov:hover {
  color: black;
}

@media (hover: hover) {
  .hov:hover {
    color: red;
  }
}
<div class="hov">Hover over me</div>

However, you may want to think through exactly which capabilities you want to test for, remembering that some devices may have both touch and mouse actions.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!