Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict the CSS for only a particular page?

Tags:

html

css

I was trying to insert another html page into an php page by using "include" and that html page is having some stylesheets imported,

When I insert that page, it disturbs my PHP page..

How can I restrict the CSS for that particular page only?

like image 819
Gaurav Avatar asked Jan 28 '26 10:01

Gaurav


2 Answers

place the imported page inside a container div, and then give it an id like:

<div id='included_page'> Your page goes here...</div>

Then add #included_page .someClass{mystyle: property;} to each and every style defined.i.e, increase the level.

like image 127
whitehat Avatar answered Jan 31 '26 07:01

whitehat


Add a class or id to each <body> and write styles accordingly like below

HTML

<body class='home'>
    Home page content
</body>

<body class='about'>
    About page content
</body>

CSS

.home .someclass{

}
.about .someclass{

}
like image 20
Pons Purushothaman Avatar answered Jan 31 '26 06:01

Pons Purushothaman