Ordinary input of type file in webpages comes with a default style and the caption, “Choose file”. The good news is that we can style and tweak it to what we want.
<input type="file" accept="image/png, image/jpg, image/gif, image/jpeg"/>
There are three steps to styling the input file in forms:
<input>
element with the type="file"
attribute inside a <label>
element. Also, we can add more elements or icons within a <label>
element.<label for="inputTag">Select Image<input id="inputTag" type="file"/></label>
input[type="file"]
tag to none
in CSS:input[type="file"]{display: none;}
label
element:label{cursor: pointer;}
We have looked at how to style the input file type that normally appears in a default “Choose file” format. One of these ways is to set the display
to none
. This way, we can style the label and add some icons.