html:
<form id="personal_info" action="..." method="post">
<legend>Personal info</legend>
<p>
<label for="fullname">Your name: </label>
<input name="fullname" id="fullname" type="text" tabindex="1" />
</p>
<p>
<label for="email">Your e-mail: </label>
<input name="email" id="email" type="text" tabindex="2" />
</p>
<p><input id="send" type="submit" value="Send" /></p>
</form>
css:
form#personal_info {
background:#dee;
width:470px;
padding:10px;
border:1px solid #000;
margin:0;
}
form#personal_info legend {
font-family:georgia, sans-serif;
font-size:1.1em;
font-weight:bold;
border:3px solid #fff;
margin-bottom:5px;
padding:3px;
width:270px;
background:#fff url(legend.gif) repeat-x center left;
}
form#personal_info label {
clear:left;
display:block;
float:left;
width:100px;
text-align:right;
padding-right:10px;
color:#888;
margin-bottom:0.5em;
}
form#personal_info input {
border:1px solid #fff;
background:#fff url(legend.gif) repeat-x top left;
padding-left:0.5em;
margin-bottom:0.6em;width:300px;
}
form#personal_info #button1 {
color:#c00;
padding-right:0.5em;
cursor:pointer;
margin-left:8px;
width:100px;
}
form#personal_info #button1:hover {
background-position:center left;
color:#000;
width:100px;
}
Input and button have the same width of 300px, but I want button to be 100px wide. What’s wrong?
See Demo
If you just apply style to
inputit will apply those styles to all theinputelement such astextbox,buttonas they are input elements.You should use
id'sto apply styles uniquely.Using
#buttondoesnot mean these styles will be applied tobuttons.What you can do is asign id’s to your input elements and then apply styles accordingly
CSS:
Alternatively you can do something like this