GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

`::file-selector-button` CSS pseudo-element

The ::file-selector-button CSS pseudo-element represents the button of an input of type="file".

The **`::file-selector-button`** [CSS](/docs/Web/CSS) [pseudo-element](/docs/Web/CSS/Reference/Selectors/Pseudo-elements) represents the button of an input of [`type="file"`](/docs/Web/HTML/Reference/Elements/input/file).

tabbed-shorter

```css interactive-example
input {
margin-top: 1rem;
}

input::file-selector-button {
font-weight: bold;
color: dodgerblue;
padding: 0.5em;
border: thin solid grey;
border-radius: 3px;
}
```

```html interactive-example
<label for="avatar">Choose a profile picture:</label><br />

<input id="avatar" type="file" name="avatar" accept="image/png, image/jpeg" />
```

## Syntax

```css
::file-selector-button {
/* ... */
}
```

## Examples

### Basic example

#### HTML

```html
<form>
<label for="fileUpload">Upload file</label>
<input type="file" id="fileUpload" />
</form>
```

#### CSS

```css hidden
form {
display: flex;
gap: 1em;
align-items: center;
}
```

```css
input[type="file"]::file-selector-button {
border: 2px solid #6c5ce7;
padding: 0.2em 0.4em;
border-radius: 0.2em;
background-color: #a29bfe;
transition: 1s;
}

input[type="file"]::file-selector-button:hover {
background-color: #81ecec;
border: 2px solid #00cec9;
}
```

#### Result

100%

Note that `::file-selector-button` is a whole element, and as such matches the rules from the UA stylesheet. In particular, fonts and colors won't necessarily inherit from the `input` element.

### Fallback example

#### HTML

```html
<form>
<label for="fileUpload">Upload file</label>
<input type="file" id="fileUpload" />
</form>
```

#### CSS

```css hidden
form {
display: flex;
gap: 1em;
align-items: center;
}
```

```css
input[type="file"]::file-selector-button {
border: 2px solid #6c5ce7;
padding: 0.2em 0.4em;
border-radius: 0.2em;
background-color: #a29bfe;
transition: 1s;
}

input[type="file"]::-ms-browse:hover {
background-color: #81ecec;
border: 2px solid #00cec9;
}

input[type="file"]::-webkit-file-upload-button:hover {
background-color: #81ecec;
border: 2px solid #00cec9;
}

input[type="file"]::file-selector-button:hover {
background-color: #81ecec;
border: 2px solid #00cec9;
}
```

#### Result

100%

## Specifications

## Browser compatibility

## See also

- [WebKit CSS extensions](/docs/Web/CSS/Reference/Webkit_extensions)
- [File and Directory Entries API](/docs/Web/API/File_and_Directory_Entries_API)
- [`<input type="file">`](/docs/Web/HTML/Reference/Elements/input/file)

source: MDN Web Docs mirror · page

Cite this

"`::file-selector-button` CSS pseudo-element". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/::file-selector-button

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·