Diff CSS styles for diff INPUT TYPE='s?

A

A Traveler

I know in a css file, i can declare a style which will apply to a given HTML
tag, specifically, i am looking at an INPUT tag. Is there any way in which i
can create a style section which will apply to a specific *type* of input??
That is, a section which applies only to [input type=text] or only to [input
type=check] or whichever?

Thanks in advance.
 
H

Hermit Dave

if you are using asp.net (assuming a. you have a cross posted and b posted
in asp.net yet... ie yes)
you use something called webcontrols. you can assign different styles to
different webcontrols.. yes even if they are of the same type like a textbox
control (which is rendered as input type = text

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
 
A

A Traveler

This doesnt actually work. Here is what i have, in my CSS, there is an INPUT
{} section, then i also have a .noborder{} section. in the input, i declare
a certain type, so all my textboxes look the same. I then use the .noborder
class on my checkboxes, because the check boxes look a little dorky with the
extra border painted around them. Only thing is, the checkboxes STILL wind
up with the border as defined in input, even though they are overriden with
a specific class.

The textboxes and chkbxs are all [asp:textbox or [asp:checkbox. The reason
is, the CssClass property on the checkbox does not actually apply to the
ACTUAL checkbox. It applies rather to the combined control which ASP.NET
renders for a checkbox of a Checkbox and either a Literal control or a Label
(im not sure if its the Lit or Lbl).


Hermit Dave said:
if you are using asp.net (assuming a. you have a cross posted and b posted
in asp.net yet... ie yes)
you use something called webcontrols. you can assign different styles to
different webcontrols.. yes even if they are of the same type like a
textbox
control (which is rendered as input type = text

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
A Traveler said:
I know in a css file, i can declare a style which will apply to a given HTML
tag, specifically, i am looking at an INPUT tag. Is there any way in
which i
can create a style section which will apply to a specific *type* of input??
That is, a section which applies only to [input type=text] or only to [input
type=check] or whichever?

Thanks in advance.
 
H

Hermit Dave

see it in action different controls having different stylesheets applied to
different controls
infact even the same type of controls

www.steptall.com

check the links near the shopping bag area. you can dig deeper if you wish.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
A Traveler said:
This doesnt actually work. Here is what i have, in my CSS, there is an INPUT
{} section, then i also have a .noborder{} section. in the input, i declare
a certain type, so all my textboxes look the same. I then use the ..noborder
class on my checkboxes, because the check boxes look a little dorky with the
extra border painted around them. Only thing is, the checkboxes STILL wind
up with the border as defined in input, even though they are overriden with
a specific class.

The textboxes and chkbxs are all [asp:textbox or [asp:checkbox. The reason
is, the CssClass property on the checkbox does not actually apply to the
ACTUAL checkbox. It applies rather to the combined control which ASP.NET
renders for a checkbox of a Checkbox and either a Literal control or a Label
(im not sure if its the Lit or Lbl).


Hermit Dave said:
if you are using asp.net (assuming a. you have a cross posted and b posted
in asp.net yet... ie yes)
you use something called webcontrols. you can assign different styles to
different webcontrols.. yes even if they are of the same type like a
textbox
control (which is rendered as input type = text

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
A Traveler said:
I know in a css file, i can declare a style which will apply to a given HTML
tag, specifically, i am looking at an INPUT tag. Is there any way in
which i
can create a style section which will apply to a specific *type* of input??
That is, a section which applies only to [input type=text] or only to [input
type=check] or whichever?

Thanks in advance.
 
P

PJ

this is a css problem...it would be helpful if you actually included the
appropriate section of the stylesheet as well as the markup.

if you have a style defined for input like:

input {
border: 1px solid green;
background: #efefef;
}

this style will apply to all <input> elements. if you need to ovverride it
for a specific set of elements, use a class as you've done.

<input type="checkbox" class="check" />

..check {
border: none;
}

Note, the checkbox will have a background of #efefef because both styles
apply to the checkbox. However, the checkbox will not have a border,
because the class style specifically defines a border of "none."

A Traveler said:
This doesnt actually work. Here is what i have, in my CSS, there is an INPUT
{} section, then i also have a .noborder{} section. in the input, i declare
a certain type, so all my textboxes look the same. I then use the ..noborder
class on my checkboxes, because the check boxes look a little dorky with the
extra border painted around them. Only thing is, the checkboxes STILL wind
up with the border as defined in input, even though they are overriden with
a specific class.

The textboxes and chkbxs are all [asp:textbox or [asp:checkbox. The reason
is, the CssClass property on the checkbox does not actually apply to the
ACTUAL checkbox. It applies rather to the combined control which ASP.NET
renders for a checkbox of a Checkbox and either a Literal control or a Label
(im not sure if its the Lit or Lbl).


Hermit Dave said:
if you are using asp.net (assuming a. you have a cross posted and b posted
in asp.net yet... ie yes)
you use something called webcontrols. you can assign different styles to
different webcontrols.. yes even if they are of the same type like a
textbox
control (which is rendered as input type = text

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
A Traveler said:
I know in a css file, i can declare a style which will apply to a given HTML
tag, specifically, i am looking at an INPUT tag. Is there any way in
which i
can create a style section which will apply to a specific *type* of input??
That is, a section which applies only to [input type=text] or only to [input
type=check] or whichever?

Thanks in advance.
 
S

Steve Fulton

A said:
I know in a css file, i can declare a style which will apply to a given
HTML tag, specifically, i am looking at an INPUT tag. Is there any way
in which i can create a style section which will apply to a specific
*type* of input??
That is, a section which applies only to [input type=text] or only to
[input type=check] or whichever?

input[type=text] { /* your styles here */ }

5.8 Attribute selectors
<URL:http://www.w3.org/TR/REC-CSS2/selector.html#attribute-selectors>

Unfortunately, this won't work in IE, even though the CSS2 spec is over
six years old! You can use it so that clients that implement the spec
will use your styles, but IE won't; or you can needlessly clutter your
HTML with code like:

<input type="text" class="text" ...>

and use a selector like

input.text { ... }
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,836
Latest member
BuyBlissBitesCBD

Latest Threads

Top