Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How to link a CSS page to my PHP script file

    Hello guys!

    I'm having problems attempting to link my CSS page to my php file. Both files are in the same folder, in addition to the other php files. The code for my php file is as follows:

    <!DOCTYPE html>
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="webcss.css" />
    <script type="text/javascript" src="validation.js"></script>
    <script type="text/javascript" src="ajax.js"></script>
    </head>
    <body>
    <h1>Student Marks</h1>

    <div id="navigation">
    <button type="button" onclick="enterMarksAjaxRequest()">
    Enter Marks
    </button>
    <button type="button" onclick="displayDataAjaxRequest()">
    Display Data
    </button>
    </div>

    <!-- This content field will be updated by various ajax calls. -->
    <div id="content">
    </div>

    </body>
    </html>


    The CSS file is called webcss.css but it's not linking up and showing any changes upon loading up on the browser using apache.

    Any ideas? Thanks for your time.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,525
    Thanks
    8
    Thanked 1,091 Times in 1,082 Posts
    Show us the .css file also.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    This hasn't a thing to do with PHP.
    Moving from PHP forum to HTML/CSS.

    It doesn't matter of the CSS is in the same directory as the PHP file. Since you are linking it in using the <link> html tag, you must place it in the path governed by the html root since its relying entirely on the client to access this. So with the just the href="webcss.css" that would indicate that webcss.css must be located directly off of the html root which is probably your ~/public_html directory.

    Edit:
    Actually, without the / in front of the path, I'm not 100% sure what the client does to resolve this (absolute or relative from the html root). I'd expect still off of the html root, but the client guys can verify.

  • Users who have thanked Fou-Lu for this post:

    beaverking1989 (12-12-2012)

  • #4
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Okay thanks for the help! Much appreciated


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •