Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

remove number input arrows from specific input

I have a number input where I want to remove the increase/decrease buttons. This is done using:

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
}

However how do I write CSS to apply these to a specific input with id myid ?

<input type="number" id="myid">

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can add the id after the element’s name with # like below:

input#myid::-webkit-outer-spin-button,
input#myid::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input#myid[type=number] {
  -moz-appearance: textfield;
}
<input type="number" id="myid">

Same goes whenever you want to target a specific element with a specific class. In this case, you will have to use . followed by the class name, e.g.

For the element below:

<input type="number" class="myclass">

The CSS selector should be formed like this:

input.myclass::-webkit-outer-spin-button,
input.myclass::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input.myclass[type=number] {
  -moz-appearance: textfield;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading