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).
(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.
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.
Classes are used for instances that appear more than once in one page e.g.:
Code:
.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.