Cascading Stylesheets – Zur Startseite Cascading Stylesheets Stil mit <Stil>

pre ♦ <pre> ... </pre> ♦ IE4+ M1 N4+ O5+ ♦ HTML 2.0, 3.2, 4.0

Das <pre>-Tag stellt vorformatierten Text dar. Der Text wird im Browser exakt in der gleichen Weise dargestellt, wie er innerhalb des öffnenden und schließenden <pre>-Tags steht, inklusive Weißraum, Tabulatoren und Zeilenumbrüchen. Zeilen und Spalten bleiben bestehen, ebenso extra Weißraum z.B. in Gedichten. Die häufigste Anwendung des <pre>-Tags liegt sicherlich in der Darstellung von Computercode innerhalb von HTML-Dokumenten.

Browser stellen den Text in einer nicht proportionalen Schrift dar. Die folgenden Tags sollten nicht innerhalb des öffnenden und schließenden <pre>-Tags stehen: big, img, object, small, sub oder sup. Bilder können also nicht innerhalb von pre-Elementen eingesetzt werden.

Das schließende Tag ist erforderlich.

Kernattribute class dir id lang onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup style title
width unerwünscht 4.0 Das Attribut width gibt die maximale Zahl von Zeichen an, die innerhalb einer Zeile stehen dürfen. Das Attribut gilt seit HTML 4 als unerwünscht.

Beispiel

Das Beispiel wird zweimal ausgegeben, einmal mit, einmal ohne Stylesheet.

<pre> 
function CheckFrames()
{	
    var strPage, strURL
    strPage = location.pathname + location.search
    strURL = location.protocol + "//" + location.hostname +
    "/index.asp?page=" + escape(strPage)
    if ((window.name != "body") || (window.parent.name != "frameset") ||
    (window.parent.parent.parent != window.parent.parent))
    {
       window.top.location.replace(strURL)
    }
}    	
</pre>

Darstellung ohne Stylesheet

function CheckFrames()
{	
	var strPage, strURL
	strPage = location.pathname + location.search
	strURL = location.protocol + "//" + location.hostname +
			"/index.asp?page=" + escape(strPage)

	if ((window.name != "body") || (window.parent.name != "frameset") ||
		(window.parent.parent.parent != window.parent.parent))
	{
		window.top.location.replace(strURL)
	}
}    	

Darstellung mit Stylesheet

function CheckFrames()
{	
	var strPage, strURL
	strPage = location.pathname + location.search
	strURL = location.protocol + "//" + location.hostname +
			"/index.asp?page=" + escape(strPage)

	if ((window.name != "body") || (window.parent.name != "frameset") ||
		(window.parent.parent.parent != window.parent.parent))
	{
		window.top.location.replace(strURL)
	}
}

 

Cascading Styleheets – Stil mit <Stil> • Das Begleitmaterial zum Buch
© media engineering Ulrike Häßler 2002 • Frechen