我应该使用CSS宽度/高度或HTML cols / rows属性来定义textarea吗? [英] Should I size a textarea with CSS width / height or HTML cols / rows attributes?

查看:107
本文介绍了我应该使用CSS宽度/高度或HTML cols / rows属性来定义textarea吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我开发包含 textarea 的新表单时,我需要指定其尺寸时遇到以下困境:

Every time I develop a new form that includes a textarea I have the following dilemma when I need to specify its dimensions:

使用 CSS 或使用 textarea 的属性 cols code> rows ?

Use CSS or use the textarea's attributes cols and rows?

每种方法的优点和缺点是什么?

What are the pros and cons of each method?

使用这些属性的语义是什么?

What are the semantics of using these attributes?

通常如何做?

推荐答案

我建议使用两者。如果客户端不支持CSS,则行和列是必需的和有用的。但作为一个设计师,我重写它们,以获得正确的大小,我希望。

I recommend to use both. Rows and cols are required and useful if the client does not support CSS. But as a designer I overwrite them to get exactly the size I wish.

建议的方式是通过外部样式表,例如

The recommended way to do it is via an external stylesheet e.g.

textarea {
  width: 300px;
  height: 150px;
}

<textarea> </textarea>

这篇关于我应该使用CSS宽度/高度或HTML cols / rows属性来定义textarea吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆