Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML pre width attribute

HTML
 width 属性

HTML pre Tag Reference HTML

 标签

实例

带有 30 个字符宽度的预格式化文本:


  

文本在pre标签中指定了宽度



  

文本包含了空格 和



  

换行



  

Try it »


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Only Firefox browser supports the width attribute.


Definition and Usage

HTML5 does not support

 width 属性。请使用 CSS 代替。

在 HTML 4.01 中,

 的 width 属性 已废弃。

width 属性Specifies每行的最大字符数。


兼容性注释

在 HTML 4.01 中,

 的 width 属性已废弃。请使用 CSS 代替。

CSS Syntax:

Some text

CSS Example: Preformatted text with a fixed width

In our CSS tutorial, you can find more about width attribute details.

**Tip:** If the text is wider than the surrounding element, the overflow property adds a scrollbar.


Syntax


## Attribute value



| Value | Description |

| --- | --- |

| *number* | 设置以字符数为单位的宽度。 |



  

---



![HTML pre 标签参考手册](https://www.runoob.com/images/up.gif) HTML 
 标签