HTML style scoped attribute | Tutorial
Tutorial -- Learning is not just about technology, but also about dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
HTML Reference Manual
- HTML Tag List (Alphabetical)
- HTML Tag List (Functional)
- HTML Global Attributes
- HTML Events
- HTML Canvas
- HTML Audio/Video
- HTML Valid DOCTYPES
- HTML Color Names
- HTML Color Picker
- HTML Color Mixer
- HTML Emoji
- HTML Character Sets
- HTML ASCII Reference Manual
- HTML ISO-8859-1 Reference Manual
- HTML Symbol Entity Reference Manual
- HTML URL Encoding Reference Manual
- HTML Language Code Reference Manual
- HTML Country/Region Code
- HTTP Status Messages
- HTTP Methods: GET vs POST
- Px/Em Conversion Tool
- Keyboard Shortcuts
HTML Tags
- <!-->
- <!DOCTYPE>
- <a>
- <abbr>
- <acronym>
- <address>
- <applet>
- <area>
- <article>
- <aside>
- <audio>
- <b>
- <base>
- <basefont>
- <bdi>
- <bdo>
- <big>
- <blockquote>
- <body>
- <br>
- <button>
- <canvas>
- <caption>
- <center>
- <cite>
- <code>
- <col>
- <colgroup>
- <command>
- <datalist>
- <dd>
- <del>
- <details>
- <dfn>
- <dialog>
- <dir>
- <div>
- <dl>
- <dt>
- <em>
- <embed>
- <fieldset>
- <figcaption>
- <figure>
- <font>
- <footer>
- <form>
- <frame>
- <frameset>
- <head>
- <header>
- <hgroup>
- <h1> - <h6>
- <hr>
- <i>
- <iframe>
- <img>
- <input>
- <ins>
- <kbd>
- <keygen>
- <label>
- <legend>
- <li>
- <link>
- <main>
- <map>
- <mark>
- <menu>
- <meta>
- <meter>
- <nav>
- <noframes>
- <noscript>
- <object>
- <ol>
- <optgroup>
- <option>
- <output>
- <p>
- <param>
- <pre>
- <html>
- <picture>
- <progress>
- <q>
- <rp>
- <rt>
- <ruby>
- <s>
- <samp>
- <script>
- <section>
- <select>
- <small>
- <source>
- <span>
- <strike>
- <strong>
- <style>
- <sub>
- <summary>
- <sup>
- <table>
- <tbody>
- <td>
- <textarea>
- <template>
- <tfoot>
- <th>
- <thead>
- <time>
- <title>
- <tr>
- <track>
- <u>
- <ul>
- <var>
- <video>
- <wbr>
HTML <style> scoped Attribute
The scoped attribute is a boolean attribute.
If present, it specifies that the styles are only for the parent element and its descendants.
Note: The scoped attribute is not supported in most browsers.
Example
Use the scoped attribute to style only the current <style> element's parent and its descendants:
<!DOCTYPE html>
<html>
<head>
<style>
p {
color: red;
}
</style>
</head>
<body>
<p>This paragraph is red.</p>
<div style="border:1px solid black;">
<p>This paragraph is red.</p>
<style scoped>
p {
color: blue;
}
</style>
</div>
<p>This paragraph is red.</p>
</body>
</html>
Browser Support
The numbers in the table specify the first browser version that fully supports the attribute.
| Attribute | |||||
|---|---|---|---|---|---|
| scoped | Not supported | Not supported | Not supported | Not supported | Not supported |
Technical Details
| Attribute Value | Description |
|---|---|
| scoped | A boolean attribute. If present, the style is scoped to the parent element. |
Related Pages
HTML tutorial: HTML Style
HTML reference: HTML <style> Tag
YouTip