3

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?

nitinr708
  • 1,393
  • 2
  • 19
  • 29
Gaurav
  • 31
  • 3

3 Answers3

2

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.

Sreekanth Reddy Balne
  • 3,264
  • 1
  • 18
  • 44
1

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{

}
Pons Purushothaman
  • 2,225
  • 1
  • 14
  • 23
1

Try this.

In Page[restrict the CSS]:

<?php $type = 'exclude'; inlcude('page_to_include.php');

page_to_include.php:

<?php if(!isset($type) or ($type !== 'exclude')) { // Things to be excluded from Page 1; }

Ref: PHP - include a php file and also send query parameters

Eugine Joseph
  • 1,552
  • 3
  • 18
  • 40