• Hello!

    I am setting up an online store and I’d like the homepage to be slightly different from the rest. On the home page, Id like establish different margins. Im assuming a need to create a new stylesheet , but where and how do I link the new stylesheet?
    The site is https://www.botanicalpharm.com
    Thank you so much in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • hi

    you don’t need a whole new stylesheet.
    In the theme’s header.php file, change the <body> tag to this
    <body<?php if(is_front_page()) echo ' id="homepage"';?>>

    On the homepage, your body tag will now say <body id="homepage">
    You can now override any existing styles for just that page.
    For example, in your present stylesheet, your sidebar is defined as
    #sidebar { width: 220px; }

    If you add this to the stylesheet:
    body#homepage #sidebar { width: 175px; }
    on the homepage only the sidebar will display as 175 pixels. On all other pages it continues displaying at 220 pixels.

    The reason is a CSS rule called specificity. What
    body#homepage #sidebar says is display an ID called sidebar as 175px wide when it is contained within an ID on body called homepage.

    The regular stylesheet definition is #sidebar Any ID named sidebar will display as 220 pixels wide. When there is more than one declaration for one display element, CSS selects the most specific one. body#homepage #sidebar is more specific than just #sidebar because it applies only to a particular case, so it “wins” because its the more specific of the two declarations.

    Thread Starter elitesalesgroup

    (@elitesalesgroup)

    Thank you , I will try your suggest and post my results.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How do I change style for one page only?’ is closed to new replies.