avoid textarea rows/cols error?

前端 未结 3 1245
遥遥无期
遥遥无期 2021-01-15 19:45

I am using a few page validation tools one problem i have is they tell me textarea must have rows and cols attribute. If i am setting this in CSS or using display:none (and

相关标签:
3条回答
  • 2021-01-15 20:21

    David's answer is ultimately the right one. A quick note about required attributes, though: Many attributes are required to be present, but are not required to have a value - so <textarea rows="" cols=""></textarea> is perfectly valid.

    Semantically, think of this as explicitly not specifying the rows or cols, which is different to <textarea></textarea> which is just ignoring the attributes completely.

    0 讨论(0)
  • 2021-01-15 20:26

    Stop using a textarea. If you want something to hold raw data, then use a <script> element (if you plan to access it with JS) or an input of type hidden (if you plan to submit it as form data).

    Don't use semantics that say "Let the user enter data" if you don't plan to let the user enter data.

    0 讨论(0)
  • 2021-01-15 20:43

    I think, it's standard solution. It would be better to give larger values though, so that browsers with disabled CSS can show them correctly. For invisible data holders you can use <div> instead of <textarea>.

    0 讨论(0)
提交回复
热议问题