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

HTML-Referenzhandbuch

HTML-Tag-Übersicht

HTML: <style> Tag

Der HTML <style>-Tag wird verwendet, um CSS in das HTML-Dokument einzubinden. Er kann in den <body>-Tag oder den <head>-Tag eingefügt werden. Standardmäßig ist die Stylinformation des <style>-Tags normalerweise im Format von CSS. Dieser Tag wird auch oft als <style>-Element bezeichnet.

Online-Beispiel

Verwenden Sie das <style>-Element im HTML-Dokument:

!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML style-Tag-Benutzung (Grundtutorials-Netz oldtoolbag.com)</title>
</head>
<style>
   h1 { color: blue; }
   .p-style{color:red;font-weight:bold;}
</style>
</head>
<body>
   <h1>HTML5 Example</h1>
   <p class="p-style">Dies ist ein Absatz mit einem style-Stil</p>
</body
</html>
Testen Sie es heraus ‹/›

Browserkompatibilität

IEFirefoxOperaChromeSafari

Alle gängigen Browser unterstützen den <style>-Tag.

Tagdefinition und Verwendungshinweise

Der <style>-Tag definiert die Stylinformationen eines HTML-Dokuments.

Im <style>-Element können Sie bestimmen, wie ein HTML-Dokument im Browser dargestellt wird.

Jeder HTML-Dokument kann mehrere <style>-Tags enthalten.

Hinweise und注意事项

Hinweis:Verwenden Sie <link> Tag.

Hinweis:Um mehr über die Kenntnisse von Stylesheets zu lernen, lesen Sie bitte unsere CSS Tutorial.

Note:If the "scoped" attribute is not used, each <style> tag must be located in the head area.

HTML 4.01 and HTML5Difference between

"scoped" attribute is HTML 5 New attribute in, it allows us to define styles for specific parts of the document rather than the entire document.
If the "scoped" attribute is used, the specified style can only be applied to the parent element and its child elements of the style element.

Attribute

New: HTML5 New attribute in.

AttributeValueDescription
mediamedia_querySpecify different media types for the style sheet.
scopedHTML5scopedIf this attribute is used, the style is applied only to the parent element of the style element and its child elements.
typetext/cssSpecify the MIME type of the style sheet.

Global Attributes

Support for <style> Tag Global Attributes of HTML.

Event Attributes

Support for <style> Tag HTML Event Attributes.

Related Articles

HTML Tutorial:HTML CSS

HTML DOM Reference Manual:Style Object