The moose likes HTML, CSS and JavaScript and the fly likes inline stylesheet overwrites attribute ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "inline stylesheet overwrites attribute ?" Watch "inline stylesheet overwrites attribute ?" New topic

inline stylesheet overwrites attribute ?

mark I thomas
Ranch Hand

Joined: Apr 07, 2008
Posts: 86
<input type="text" size="20" style="width: 200px";>


1. if I don't set style="width: 200px", then the text field looks like 20 char long. After I add that style=.., it looks as long as 200. So whenever there is inline stylesheet, it automatically overwrites the duplicated attributes setting, correct ?

2. when we say 200px, does it have same length as size="200" (no unit here) ?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

1. Apparently. It's kind of bad form to include competing properties. Pick one or the other. I almost always prefer CSS as size gives a number of characters and is imprecise

2. Depends upon context, but usually in CSS omitting a unit defaults to pixels. size="200" is not the same as "width: 200px" as size is in units of characters.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: inline stylesheet overwrites attribute ?
It's not a secret anymore!