Skip to content Skip to sidebar Skip to footer

Accessing A Stylesheet From A Php File

So im new to php, but from what I can tell normal html should work OK in a .php file. However in my .php file it does not access my stylesheet and other assets such as pictures. I

Solution 1:

You don't need to wrap it in <style> tags:

<head>        
    <link rel="stylesheet"type="text/css" media="screen" href="stylesheet.css">
    <meta charset="utf-8"/>
</head>

Also, learn about relative and absolute paths:

Check this out: Absolute vs. relative paths

./stylesheet.css --- Same folder as file being called

stylesheet.css --- Same folder as file being called

/stylesheet.css --- Root of project (webroot)

$_SERVER['DOCUMENT_ROOT'] --- Full path of to document/web root

$_SERVER['DOCUMENT_ROOT'] . '/stylesheet.css' --- Full path to stylesheet if in document root.

Post a Comment for "Accessing A Stylesheet From A Php File"