Search 
DailyCoding > Design

Apply CSS to html INPUT control based on type attribute

how we can add css to any input element based on the type attribute of INPUT to control the stylesheet
Author admin on May 20, 2008 4 Comments
Rate it    (Rated 3 by 9 people)
5,790 Views

If you want to add common look to all control in you website then you generally specify css for that element in your style sheet. Doing this will apply same look and feel to all element of that particular category. For example for input element you can add in CSS like

input
{
  border-right: #a9a9a9 1px solid;
  padding-right: 4px;
  border-top: #a9a9a9 1px solid;
  padding-left: 4px;
  padding-bottom: 4px;
  border-left: #a9a9a9 1px solid;
  padding-top: 4px;
  border-bottom: #a9a9a9 1px solid;
}

But there are different types under input element like text, button, checkbox, submit, password etc. Apply CSS to input element will be reflected of all the types of the input. To control this we can specify the type attribute in CSS.

input[type="text"]
{
  border-right: #a9a9a9 1px solid;
  padding-right: 4px;
  border-top: #a9a9a9 1px solid;
  padding-left: 4px;
  padding-bottom: 4px;
  border-left: #a9a9a9 1px solid;
  padding-top: 4px;
  border-bottom: #a9a9a9 1px solid;
}

input[type="button"]
{
  border-right: #a9a9a9 2px solid;
  padding-right: 2px;
  border-top: #a9a9a9 2px solid;
  padding-left: 2px;
  padding-bottom: 2px;
  border-left: #a9a9a9 2px solid;
  padding-top: 2px;
  border-bottom: #a9a9a9 2px solid;
}
CSS | Html

Discussion

Md.salim Bhuyan On Feb 26, 2009 11:28 AM
Thanks for your helping site.

Mohsin On Mar 31, 2009 09:38 PM
input[type="button"] - this will not work in IE ,if any body knows solution then plz help me. i have also tried "input.text" but still not working in IE

Alex On Jun 14, 2009 07:24 AM
try: input[type="submit"]

Lars On Nov 26, 2009 02:33 AM
Just add class="submit" and input.submit should work for all browsers ;->

Leave a Comment

Name
Email Address
Web Site
© Copyright 2008 Daily Coding • All rights reserved