PDA

View Full Version : Style a submit without a class


Ultragames
02-02-2006, 06:58 PM
I know i can make a class for a submit button, like this:

.mySubmit {
/* blah */
}

<input type="submit" class="mySubmit">


But how can I do this with out a class?

Something like:
.MyForm input type:submit
or something.

Can this be done?

blain
02-02-2006, 08:23 PM
kind of

lets say you had the following code

<div id="container">
<h2>This is an example</h2>
<p>blah blah blah<span>blah</span>blah</p>

Then you could use the following css to apply formatting to the span tag

#container p span {}

So in theory you could do the same for your submit button.

Does that make sense?

Ultragames
02-02-2006, 09:44 PM
Thats all fine if they are seperate tags. But im talking about styling all <input> tags one way, yet the <input type="submit"> gets its won style, WITH OUT a class.

oldcrazylegs
02-02-2006, 10:05 PM
<input type="submit" style="background-color:white; color:black;" />

Go to http://www.w3schools.com/css/css_reference.asp

Ultragames
02-02-2006, 10:08 PM
Neither of you have answered my questions.

I don't need a link to W3 on basic CSS. I know CSS.

I am simply asking how to apply a class to a submit, without putting ANYTHING in the submit tag to do it. You should be able to apply a class to it the same way you would with Blain's cascading content method.

A rule that states "This class applies to any submits inside any inputs inside this table"

Does anyone know how to do what I'm talking about?

GJay
02-02-2006, 11:02 PM
input[type=submit] {
/*styles here*/

}
should work

[edit] had a mental block

Ultragames
02-02-2006, 11:21 PM
I can't get that to do anything. But your trying to do what I'm after. Maybe theres a slight syntax error?

mark87
02-02-2006, 11:22 PM
It's because that doesn't work in IE.

Ultragames
02-02-2006, 11:24 PM
Dosnt work in FF either

medigerati
02-03-2006, 04:16 AM
change your <input type="submit"> to <button type="submit"></button> and style it using form button {}

Just an idea...

jkd
02-03-2006, 05:38 AM
input[type="submit"] {}

Will work in Firefox, Safari, Opera, and even IE7. What may not work is certain properties, since form widgets are notoriously difficult to style cross-browser.

oldcrazylegs
02-04-2006, 07:49 PM
It's your own fault. You weren't very clear on what you wanted. Yes you can do that.

<style type="text/css">
div#content input {style rules here}
</style>
<div id="content">
<input type="submit" />
</div>

if you have two inputs but only want to style the last one do this.

<style type="text/css">
div#content input input {style rules here}
</style>
<div id="content">
<input type="submit" />
<input type="submit" />
</div>

read eric meyers books or join his css mailing list http://www.css-discuss.org/ for more information.

_Aerospace_Eng_
02-04-2006, 07:56 PM
if you have two inputs but only want to style the last one do this.

<style type="text/css">
div#content input input {style rules here}
</style>
<div id="content">
<input type="submit" />
<input type="submit" />
</div>

That is incorrect. The last input is not in the previous input so it will not be styled.