how to apply css style only to homepage

827 Views Asked by At

So I have a SMF forum and I need to apply a background image only to the homepage. when I just simply add the style to the .body it does change the homepage background but also change in other sections as well, eg: forums boards and posts. So I just only want to display the background image on the homepage and it should not apply to the other forum sections. Is this possible ?

2

There are 2 best solutions below

2
CodeRomeos On BEST ANSWER

It is possible. Simplest way to do this is to add a class in homepage body element.

<html>
---
<body class="has-background-img">
---
---
</body>

further, remove this class from other pages where you do not want background image to appear.

0
Jilvin Jacob On

If you want the background only on your homepage, it's better you use the inline styling method.

<html>
...
...
<body style="background-image: url("gradient_bg.png");">
...
...
</body>
</html>

CSS Background CSS How to