Apply size to a textarea, unless it has the attribute "Rows"

Asked

Viewed 55 times

1

I have a textarea which is formatted with the following rule:

.wm-form textarea{
  min-height:100px;
  resize: vertical;
  width:100%;
  border-radius:4px;
  border:1px solid #ccc;
}
<form class="wm-form">
  <textarea></textarea>
</form>

But I wish that when mine textarea had the attribute rows (that would affect the size of the textarea), the size defined in min-height be applied.

How to do this?

1 answer

4


use the not to make a selection by the textarea that does not have the attribute rows:

.wm-form textarea {
  resize: vertical;
  border-radius:4px;
  border:1px solid #ccc;
  width:100%
}

.wm-form textarea:not([rows]){
  min-height:100px;
}
<form class="wm-form">
  <textarea></textarea>
</form>

<form class="wm-form">
  <textarea rows='10'></textarea>
</form>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.