Use the scoped attribute to specify that the styles only apply to the parent element and the element’s child elements −
Example
<!DOCTYPE html>
<html>
<head>
<style>
h2 {
color:yellow;
}
</style>
</head>
<body>
<div>
<style scoped>
h2 {
color:grey;
}
</style>
<h2>Grey Heading</h2>
</div>
<h2>Yellow Heading</h2>
</body>
</html>