You can do this.
email = forms.EmailField(label=_("E-mail"),
widget=forms.TextInput(attrs={'placeholder': 'Your Email', 'class':'your_css_code'}))
Question
Ok, so I've installed the django-registration app and, for the register feature, I have added a widget for the email to make a placeholder:
email = forms.EmailField(label=_("E-mail"),
widget=forms.TextInput(attrs={'placeholder': 'Your Email'}))
I prefer to use a placeholder, instead of a label.
Now, my question is: how to style the placeholder? add some colour, change the placeholder size and font etc Thanks
Solution
You can do this.
email = forms.EmailField(label=_("E-mail"),
widget=forms.TextInput(attrs={'placeholder': 'Your Email', 'class':'your_css_code'}))
OTHER TIPS
I was having issues with this as well, but then I realized that you don't want to style the placeholder within your Django form. Just add the following css to your style sheet and you'll be good to go.
::-webkit-input-placeholder {
color: rgba(255, 255, 255, .5);
}
:-moz-placeholder { /* Firefox 18- */
color: rgba(255, 255, 255, .5);
}
::-moz-placeholder { /* Firefox 19+ */
color: rgba(255, 255, 255, .5);
}
:-ms-input-placeholder {
color: rgba(255, 255, 255, .5);
}