html - php require method wont display css styling -
i created index.php
file that's uses <?php require("sidebar.html"); ?>
include sidebar; html element of sidebar shows, css styling isn't showing. i've search google , tried different method it's not showing, highly appreciated.
the sidebar.html
located in html/
folder. , index.php
located in root/
folder
the css styling sidebar being reference within sidebar.html
file
my css
file located in css/
folder
new web development; trying make sidebar can call on every page instead of hard-coding every page.
when include html file php script, path supporting files (i.e css,js or referenced in html document) listed in html file needs relative php script in have included html. if have index.php in directory named home
, include html page in named sidebar.html (let's consider path file home/foo/sidebar.html
) contains 1 or more link elements in head element reference css stylesheets saved in same directory, can't write href attribute of link elements this:
<link rel="stylesheet" href="style.css" />
you need write:
<link rel="stylesheet" href="foo/style.css" />
happy coding :)
Comments
Post a Comment