Search code examples
djangoformswidgetstylesregistration

Django - how to style the placeholder of a form field?


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'}))