In an Android layout xml file one can do something like this …
<EditText android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/username" />
<EditText android:id="@+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="@string/password" />
which results in a GUI that looks like this: 
How would I create that same effect for a HTML form with CSS?
You can use the
placeholderHTML5 attribute, for example:Most browsers are compatible with this feature, except Internet Explorer (see comment by jcater). You can use, for example, jquery-placeholder to add support for legacy browsers (even IE6!).