Jump to content
xisto Community
vdhieu84

Css For Input Text Only I dont think there is a solution but...

Recommended Posts

There are two ways to do this. The first is the 'proper' syntax - the second requires a new class:<STYLE type="text/css">input[type=text] {width: 300px;background-color: cyan;}input.text {width: 300px;background-color: yellow;}</STYLE><FORM><input type="text"><br><input class="text" type="text"><br><input type="text"><br><input type="submit"></FORM>

Share this post


Link to post
Share on other sites

There are two ways to do this. The first is the 'proper' syntax - the second requires a new class:
<STYLE type="text/css">

input[type=text] {
width: 300px;
background-color: cyan;
}

input.text {
width: 300px;
background-color: yellow;
}

</STYLE>

<FORM>
<input type="text"><br>
<input class="text" type="text"><br>
<input type="text"><br>
<input type="submit">
</FORM>

Excellent info thanks, what about styling the button of the FILE input field??? is there a way to change for example the color and background color of this input field???

Best regards,

Share this post


Link to post
Share on other sites

To specify an element with only certain attributes set, use this:

  exampletag[exampleattrib=examplevalue]

For example, a paragraph with the height set to 300 will have a red background:

 p[height=300] { background: #ff0000; }

 <p height="300">This should have a red background.</p>

Hope I helped :)

Share this post


Link to post
Share on other sites
Bad practice for CSSCss For Input Text Only

Typically, you do not want inline CSS. This avoids the point of CSS and logical separation from mark up and styles.

-reply by Mike

Share this post


Link to post
Share on other sites

I know I'm resurrecting an old post, but this really bugged me

  "Well, I always try to avoid as much class and id as I can since alongThe way when we writing code, once in a while I will forget to put these attribute in. Even though I will eventually figure out where in my code I missed, it's still better to have a "global" setting which will makes sure consistency for me. "

Hopefully in the past few years you've figured out to not be so lazy with your learning.  You're making your code more complex than it needs to be by not adhering to web standards simply because you're forgetful.  I know this was 5 years ago, but I just needed to throw that out there.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.