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

HTML Referenzhandbuch

Vollständiges Verzeichnis der HTML-Tags

HTML: <span> Tag

Das HTML-<span>-Element ist ein allgemeiner Inline-Content-Container für Phraseninhalte und hat keine spezielle Semantik. Es kann verwendet werden, um Elemente zu gruppieren, um eine bestimmte Stylisierung zu erreichen (durch Verwendung von Class- oder Id-Attributen), oder diese Elemente haben gemeinsame Attribute, wie z.B. lang. Es sollte nur verwendet werden, wenn keine anderen angemessenen semantischen Elemente vorhanden sind. Das <span>-Element ist sehr ähnlich zum <div>-Element, aber das <div> ist ein Block-Element, während das <span> ein Inline-Element ist .

Online-Beispiel

Verwenden Sie das <span>-Element, um einen Teil des Textes zu färben:

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>Grundlagen-Tutorial(oldtoolbag.com)</title> 
</head>
<body>
<p>Hier siehst du <span style="color:blue;font-weight:bold">blauen</span> der Himmel, noch <span style="color:green;font-weight:bold">green</span> of the grass.</p>
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the <span> tag.

Definition and Usage of Tags

The <span> is used to combine inline elements within a document.

The <span> tag does not have a fixed format. It only produces visual changes when styles are applied to it. If no style is applied to the <span>, the text within the <span> element will not have any visual difference from other text.

The <span> tag provides a way to isolate a part of the text or a part of the document.

Tips and Notes

Tip:The text enclosed by the <span> element in HTML, you can define its style using CSS or manipulate it with JavaScript.

HTML 4.01 and HTML5Differences between

None.

Global Attributes

<span> Tag supports Global Attributes of HTML.

Event Attributes

<span> Tag supports HTML Event Attributes.