Hi, I have a common submit button code like this <input type="submit" /> I need to apply css to this code but normally what I do is to add id or class to this button and then apply the css normally. This time, the only problem is I can't modify the code <input type="submit" /> because it came from other source. So just wondering is there a way to work through this? my question is, is there any way to apply ccs without an id or class name? can we add id or class name to an input element using javascript or something else? thanks
You can always try adding a style attr. to the input itself. <input type="submit" style="font-size:11px; background-color:#F00; color:#FFF;" />
Give them a class like this < input type="submit" class="submit-button"> and design your css for the "submit-button" class. Hope it helps
here's an example, customize CSS for input as per your requirement input { border:1px dashed #000; height:25px; background-color:#FF0000; color:#FFFFFF; } HTML:
He has already stated that he doesn't have access to the stylesheet, and adding classes, attributies, etc. is out of the question.
nehrav, if i apply css to input tag, it will apply the css to all inputs.. But i just want to apply a css style specifically to the submit button. btw kelly, i just dont have access to change the block of code directly. But i do have access to add external css to apply to the page in general, and i do have access to add html codes or what so ever around that specific block of code. p/s : the specific block of code that I mentioned is in fact a html form that come from external source. Any ideas anyone?
yeah, i'm thinking about using javascript to dynamically add the id attribute to that submit button. But since the button and the html form itself dont have a name attribute, it will be a hard work. =(
In your stylesheet, input[type=submit] { ... } Code (markup): Older IEs will fail, but with the restrictions you have, some failure is expected. The alternative is to use javascript to add the class or id attribute. The js solution will fail for all who don't have js enabled. cheers, gary
Thanks for the answer.. odd it may seems, but i opt to use the javascript solution. The block of code that I want to apply css came from a javascript call. So before my code fail, the javascript call will fail first. So, we just assume here that javascript is enabled. DO you have any ideas on the javascript solution?
Without more info, I can only guess at a method. I may be doing that anyway, as I'm not all that expert at js. Upload a small test case to a public facing server, and give us a link. cheers, gary