How to change the font and font size of an HTML input tag?

<input id="txtComputer">

How do I make my text inside the input tag bigger? I want to make it 24 size font. It would also be good if I can change the font from the default

386536 次浏览

In your 'head' section, add this code:

<style>
input[type='text'] { font-size: 24px; }
</style>

Or you can only add the:

input[type='text'] { font-size: 24px; }

to a CSS file which can later be included.

You can also change the font face by using the CSS property: font-family

font-family: monospace;

So you can have a CSS code like this:

input[type='text'] { font-size: 24px; font-family: monospace; }

You can find further help at the W3Schools website.

I suggest you to have a look at the CSS3 specification. With CSS3 you can also load a font from the web instead of having the limitation to use only the most common fonts or tell the user to download the font you're using.

in your css :

 #txtComputer {
font-size: 24px;
}

You can style an input entirely (background, color, etc.) and even use the hover event.

<input type ="text" id="txtComputer">

css

input[type="text"]
{
font-size:24px;
}