View Full Version : How to change the color of the text in a inputbox?

12-28-2003, 01:56 PM
It's all in the subject!!! I'v tried everything. I thought this should do it, but it don't. font-family: 'Verdana'; font-color: '#666666';

12-28-2003, 02:31 PM
<style type="text/css">

12-28-2003, 02:33 PM
<input type="text" style="font-family: verdana, helvetica, serif; color: #666;" />

12-28-2003, 06:44 PM
Originally posted by fredmv

<input type="text" style="font-family: verdana, helvetica, serif; color: #666;" /> Eww, inline styles

12-28-2003, 07:00 PM
Originally posted by me'
Eww, inline styles I usually use external stylesheets as well, but in this specfic instance I didn't know if he wanted only one textbox to have a different style or not. Therefore, I assumed he only needed it for one textbox and it wouldn't make sense to create a create an embedded stylesheet (maybe an id would have been good in this case but I wanted to keep it even simpler therefore not requring any selectors whatsoever).

12-28-2003, 07:03 PM
(sorry if this appears patronising fredmv, this is aimed at anyone that reads this thread, and not really you)

IDs would still be better than inline styles. I accept it as convenience of example, but in practice, you're better off reffering to it with an ID if there's only one you need, or a class if there's more than one. Using inline styles mixes your style and content, and defeats the entire point of CSS.

12-28-2003, 07:06 PM
No offense taken on my part. ;)

I completely agree. But as you say, in this specific instance I just wanted simpliciity for the example, but when used in real context I would, myself, also use an id if there was only one element in which needed that specific style.

Paul Jr
12-28-2003, 07:26 PM
I once heard someone say...

If it's style to be used across your entire site, on every page, slap it in an external stylesheet.

If it's going to be used multiple times, but only one on page, stick it in some <style> tags.

If it's going to be used only once, on one page, use inline styles.

Not the exact wording, but something to that affect.

I go by this method; makes sense to me.

12-28-2003, 07:34 PM
That is wrong either way.

Classes are used for instances that appear more than once in one page e.g.:

.text {
color: #777;
text-decoration: none;
That will pick up any tag with class="text" stuck on it.

ID's are used for instances that may appear once, e.g. a logo, and have '#' instead of '.' used, with id="text" instead, where '.text' would be '#text'.

You don't just stick in <style> tags, and you avoid inline tags as like using tables for layouts.