Latest web development tutorials

HTML style scoped attributes

HTML style tags Reference Manual HTML <style> tag

Examples

Using the scope attribute describes the style <div> element:

<div>
<style type="text/css" scoped>
h1 {color:red;}
p {color:blue;}
</style>
<h1>这个标题是红色的</h1>
<p>这个段落是蓝色的。</p>
</div>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Firefox supports only attribute scoped attributes.


Definition and Usage

scoped attribute is a Boolean attribute.

If you use this attribute, then the style only apply to the parent element style element and its child elements.


Differences between HTML 4.01 and HTML5

scoped attribute is new in HTML5 attributes.


Differences between HTML and XHTML

In XHTML, the property is not allowed shorthand, scoped attribute must be defined as: <style scoped = "scoped" />.


grammar

<style scoped>


HTML style tags Reference Manual HTML <style> tag