Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rule works inline but not in stylesheet? 4

Status
Not open for further replies.

rockyroad

Programmer
Feb 22, 2003
191
US
I have this rule in my forms.css -

Code:
#horizontalForm input.submit
{
	margin-left:45px;
	color:#FFFFFF;
	background-color:#FF0000;
}
(the form id=horizontalForm)

which does not work...

I am trying to do this - which does...

Code:
<input type="submit" value="Submit" style="margin-left:45px; color:#FFFFFF; background-color:#FF0000; ">

I suspect my scope is wrong? Can anyone help, I am stumped...


 
The rule doesn't do what you think it does...
Code:
#horizontalForm input.submit
Talks about an element with ID=horizontalForm that has a child input element with a class called "submit". An immediate fix for you is to add a class="submit" to the <input>.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
[tt]#horizontalForm input.submit[/tt]

Talks about an element with ID=horizontalForm that has a child input element with a class called "submit".

Just to clarify Jeff's statement (which might otherwise be taken the wrong way round) - the rule will apply to an input element with a class called submit, that's inside some other element with an id of horizontalForm.

What the OP perhaps meant was
Code:
#horizontalForm input[type=submit]
This works just fine on modern browsers, but sadly not on IE.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Thanks. That worked. Now I have another question...

Right now I am using some .CSS like this...

#horizontalForm fieldset
{
display: block;
margin:0;
padding:0;
border:0;
margin-bottom:15px;
}

But I see a potential problem, if I want to use more than one form on a page, i would need to have 2 forms referencing id="horizontalForm".. a .CSS no-no...

So my question is could I refernce a class the same way, i.e. ...

use <form class ="horizontalForm">

and reference

.horizontalForm fieldset
{
display: block;
margin:0;
padding:0;
border:0;
margin-bottom:15px;
}

or

.horizontalForm fieldset.radio input

or

.horizontalForm input.submit
{
margin:0 0 0 10px;
padding:1px;
color:#FFFFFF;
background-color:#FF0000;
font-weight:bold;
font-size:100%;
font-family:Arial, Helvetica, sans-serif;
border: 1px solid #CCCCCC;
}

will any of these work the same way?

Thanks
 
They will all work in the same way with a little less specifity as the ids. But I am pretty sure that will not be bothering your examples though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top