You can use the navigator API to detect whether the device browser is a tablet or not in the HTML webpage. Of course, you have to use JavaScript and Regular expression with it.
Must Read: –JavaScript detect mobile device browser
Example code JavaScript detect tablet
One line function to detect mobile devices with JavaScript.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<!DOCTYPE html> <html> <head> <script type="text/javascript"> const userAgent = navigator.userAgent.toLowerCase(); const isTablet = /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(userAgent); alert(isTablet); </script> </head> <body> </body> </html> |
Output:

Do comment if you have any questions and suggestions on this topic.
Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version