jack rackham jack rackham - 4 months ago 7
HTML Question

Python: How to override text area in form using CSS

Hi I would like to ask on how to override the text area in form using CSS.
This is my codes:

forms.py

description = forms.CharField(widget=forms.Textarea(attrs={'class': 'comment-control'}))


CSS:

.comment-control {
background-color: #fff;
width: 830px;
height: 110px;
}


HTML

<form name="add_comment" id="comment-form" action="{% url 'comment:create' refId=refApp.id refApp=thisApp %}" method="post">
{% csrf_token %}
{{ form }}
</form>


I want to change the layout of the textarea of form using CSS but it is not being inherited, I appreciate your help. Thank you

Answer

you should do something like this:

description = forms.CharField(widget=forms.Textarea(attrs={'cols':'4', 'rows':'50'}))
Comments