CSSStyleDeclaration parentRule Property
The parentRule property is used to return the CSSRule Object that represents a CSS rule-set that contains selector and declaration block.
Syntax: It is used to return the parentRule property.
object.parentRule
Return Value: It returns the CSSRule object.
Example: To return the parentRule property:
<html> <head> <title> CSS | Style Declaration parentRule Property </title> <style> body { text-align: center; } h1 { color: green; } #p1 { color: green; font-size: 20; } </style> </head> <body> <h1> GeeksforGeeks </h1> <p id="p1"> parentRule Property </p> <p> Click the button to return the parentRule property </p> <button onclick="myFunction()"> Get parentRule </button> <p id="gfg"></p> <!-- Script to get parentRule property --> <script> function myFunction() { var x = document.styleSheets[ 0].rules[2].style.parentRule.cssText; document.getElementById("gfg").innerHTML = x; } </script> </body> </html> |
chevron_right
filter_none
Output:
- Before clicking on the button:

- After clicking on the button:

Supported Browsers: The browsers supported by Style Declaration parentRule Property are listed below:
- Google Chrome
- Internet Explorer 9.0+
- Firefox
- Opera
- Safari
Recommended Posts:
- CSSStyleDeclaration getPropertyValue() Method
- CSSStyleDeclaration getPropertyPriority() Method
- CSSStyleDeclaration item() Method
- CSSStyleDeclaration setProperty() Method
- CSS | transition-property Property
- CSS | all Property
- CSS | nav-down property
- CSS | nav-up property
- CSS | nav-right property
- CSS | top Property
- CSS | right Property
- CSS | clip Property
- CSS | perspective Property
- CSS | flex Property
- CSS | border-right Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



