File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Font-weight of Browse button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Font-weight of Browse button" Watch "Font-weight of Browse button" New topic

Font-weight of Browse button

Sindhura Lakshmi

Joined: Jun 18, 2009
Posts: 13
Hi ,

I am trying to apply styles to my html browse button.I could change the font size of the "Browse" text on the Browse button but i want to make it BOLD ?
Sindhura Lakshmi

Joined: Jun 18, 2009
Posts: 13
Hi ,

Can Any one Help

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

If you are talking about the button created as part of the <input type="file"> element, there are limited options for styling. I do not believe that you will be able to affect the style of the button.

I have read about techniques where the file control is hidden and proxied by stylable elements, but I've never been able to get is working adequately in a cross-browser fashion. (Didn't try too hard though.) You might do a search and see if someone else has been successful.

[Asking smart questions] [About Bear] [Books by Bear]
Sindhura Lakshmi

Joined: Jun 18, 2009
Posts: 13
Hi ,

I was able to work this with the help of css and javascript but i am not able to edit the path which is selected in the browse input field ..

My code is as follows :
html file :

<style type="text/css">
#mybrowse { font-weight: bold; }

div.fileinputs {
position: relative;

div.fakefile {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;

input.file {
position: relative;
text-align: right;
-moz-opacity:0 ;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 2;
<script type="text/javascript">
var W3CDOM = (document.createElement && document.getElementsByTagName);

function initFileUploads() {
if (!W3CDOM) return;
var fakeFileUpload = document.createElement('div');
fakeFileUpload.className = 'fakefile';
var x = document.getElementsByTagName('input');
for (var i=0;i<x.length;i++) {
if (x[i].type != 'file') continue;
if (x[i].parentNode.className != 'fileinputs') continue;
x[i].className = 'file hidden';
var clone = fakeFileUpload.cloneNode(true);
x[i].relatedElement = clone.getElementsByTagName('input')[0];
x[i].onchange = x[i].onmouseout = function () {
this.relatedElement.value = this.value;

function modify(){
alert("Modification Success");



<div class="fileinputs">
<input type="file" class="file" onchange="initFileUploads()" />
<div class="fakefile" >
<input />
<input type="button" value="Browse"id="mybrowse" /> </div>



Please suggest ideas
I agree. Here's the link:
subject: Font-weight of Browse button
It's not a secret anymore!