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

HTML Referenzhandbuch

Vollständiges Verzeichnis der HTML-Tags

HTML Style Scoped Attribut

Das Attribut "scoped" ist ein boolesches Attribut. Wenn das Attribut "scoped" verwendet wird, wird der Style nur auf den Elternelement und die Kinder des style-Elements angewendet.

 HTML <style> Tag

Online-Beispiel

Verwenden Sie das Attribut "scope", um die Stylesheet des <div>-Elements zu beschreiben:

<div>
<style type="text/css" scoped>
h1 {color:yellow;}
p {color:green;}
</style>
<h1>This title is yellow</h1>
<p>This paragraph is green.</p>
</div>
Test see ‹/›

Browser Compatibility

The numbers in the table indicate the first browser version number that supports the attribute.
attribute




scopedNot supportedNot supported21.0Not supportedNot supported

Definition and Usage

The scoped attribute is a boolean attribute.

If the scoped attribute is used, the style is only applied to the parent element of the style element and its child elements.

HTML 4.01 with HTML5differences

The scoped attribute is an HTML5 new attributes added.

Differences between HTML and XHTML

In XHTML, attributes are not allowed to be abbreviated, the scoped attribute must be defined as: <style scoped="scoped" />。

Syntax

<style scoped>
 HTML <style> Tag