Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add css for specific input type text

When I was trying to add some input fields with css

I got a problem

I couldn't make more than one css for some input fields

this is the fields I have

<input type="text" name="firstName" />
<input type="text" name="lastName" />

and the css is

input
{
   background-image:url('images/fieldBG.gif');
   background-repeat:repeat-x;
   border: 0px solid;
   height:25px;
   width:235px;
}

I want to make the first field (firstName) with this css

input
{
   background-image:url('images/fieldBG.gif');
   background-repeat:repeat-x;
   border: 0px solid;
   height:25px;
   width:235px;
}

and the second one (lastName) with this css

input
{
   background-image:url('images/fieldBG2222.gif');
   background-repeat:repeat-x;
   border: 0px solid;
   height:25px;
   width:125px;
}

help please :-)

like image 520
sulaiman Avatar asked May 14 '12 18:05

sulaiman


People also ask

Can we change input type with CSS?

No. CSS is a presentation language. It cannot be used to alter the semantics and structure of a document.

How do you input CSS in HTML?

CSS can be added to HTML documents in 3 ways: Inline - by using the style attribute inside HTML elements. Internal - by using a <style> element in the <head> section. External - by using a <link> element to link to an external CSS file.

What is the correct selector for targeting all text inputs?

CSS attribute selector is used to targeting an input text fields. The input text fields of type 'text' can be targeting by using input[type=text].

What is styling forms with CSS?

CSS form is used to create interactive forms for users and provides many ways to set the style. There are many CSS properties available that can be used to create and style HTML forms to make them more interactive.


1 Answers

You can style by type or name the form elements using CSS.

input[type=text] {
    //styling
}
input[name=html_name] {
    //styling
}
like image 197
Andrew Avatar answered Oct 03 '22 13:10

Andrew