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

HTML Reference Manual

HTML Tag Directory

HTML style scoped attribute

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 <style> tag

Online Example

Use the scope attribute to describe the style of the <div> element:

<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 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