Open In App

How to hide number input spin box using CSS ?

In this article, we will see how to hide the number input’s spin box in HTML5. The Spinbox or Spinner in HTML allows to increase or decrease the input number with the help of up-arrow & down-arrow, placed within the box, whose value defines in a range of real numbers. The spin box facilitates selecting or inputting a wide range of real numbers, which is mainly utilized to insert the number in HTML. It generally appears when the value of the <input> type is selected as a number, tel, & similar other cases. There are various CSS properties & extensions that can be implemented to hide the input’s spin box, which is discussed below:

Approach:



Example: The example code demonstrates how to practice the above properties and remove the HTML5 number input’s spin box.




<!DOCTYPE html>
<html>
  
<head>
    <style>
        /* For Chrome and Safari  */
          
        input[type="number"]::-webkit-outer-spin-button,
        input[type="number"]::-webkit-inner-spin-button 
        {
            -webkit-appearance: none;
            margin: 0;
        }
        /* For Firefox  */
          
        input[type="number"] {
            -moz-appearance: textfield;
        }
    </style>
</head>
  
<body>
    <center>
        <h1 style="color:green">
            GeeksforGeeks
        </h1>
        <h3>
            HTML5 number input without a spin box.
        </h3>
        <input type="number" /> 
    </center>
</body>
</html>

Output: A HTML5 number input without its default spin box.



 


Article Tags :