English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML reference manual

Complete list of HTML tags

HTML pre width attribute

The pre width attribute specifies the maximum number of characters per line. Only Firefox supports the width attribute from version 1.0 to 29.0.

 HTML <pre> etichetta

Online example

Formatted text, width of 40 characters:

<!DOCTYPE html>
<html>
<head>
<title>HTML: <width> name attribute - Basic Tutorial Website (oldtoolbag.com)</title>
</head>
<body>
<p>Normal pre:</p>
<pre>
Text in a pre element is displayed in a fixed-width
font, and it preserves both spaces and
line breaks
</pre>
<p>Define the specific width of Pre:</p>
<pre width="40">
Text in a pre element is displayed in a fixed-width
font, and it preserves both spaces and
line breaks
</pre>
</body>
</html>
Test to see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

 Firefox supporta l'attributo width dalla versione 1.0 alla 29.0.

Definizione e uso

HTML5 non supporta l'attributo width del <pre>. Usa CSS invece.

Nel HTML 4.01, l'attributo width del <pre> è obsoleto.

L'attributo width specifica il numero massimo di caratteri per ogni riga.

Commenti di compatibilità

Nel HTML 4.01, l'attributo width del <pre> è obsoleto. Usa CSS invece.

Sintassi CSS: <div style="width:200px;overflow:auto"><pre>Some text</pre></div>

CSS Esempio: testo preformato con larghezza fissa

Nel nostro tutorial CSS, puoi trovare ulteriori informazioni su Attributo width dettagli.

Suggerimento:Se la larghezza del testo supera la larghezza dell'elemento circostante, l'attributo overflow aggiunge una barra di scorrimento.

Sintassi

<pre width="number">

Valore dell'attributo

ValoreDescrizione
numberImposta la larghezza in numero di caratteri.
 HTML <pre> etichetta