0

I have included my css into application folder in codeigniter Folders: system application application/css/style.css

I am unable to load the my view file if I include css file like this <link rel="stylesheet" href="<?php echo base_url();?>css/style.css" type="text/css" media="screen"/>

What could be the reason? Please help me to solve this issue.

        <html>
        <head>
         <link rel="stylesheet" href="<?php echo base_url();?>css/style.css" type="text/css" media="screen"/>
        </head>
        <body>
            <table width="100%" border="1" >
                <td   align="left"><h1>hellooooooo</h1></td>
            </table>
        </body>
    </html>
6
  • 1
    When you view the source of the HTML what's the value of the href attribute? Commented Jan 11, 2013 at 18:20
  • lookt at the generated html code and u will see wrong path to the css file Commented Jan 11, 2013 at 18:22
  • @David i get only upto <html><head> Commented Jan 11, 2013 at 18:23
  • @vlcekmi3 generated html code shows only ` <html><head> ` . I after this it skips remaining codes Commented Jan 11, 2013 at 18:26
  • When you go to the page in your browser and view the page source you should see at least <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" /> between the <head></head> tags. Commented Jan 11, 2013 at 18:27

4 Answers 4

0

base_url() should refer to your URL like yoursite.com/. so it likely not pointing to the code igniter directory. try putting your css in your home directory like yoursite.com/css/style.css I believe this is also what is suggested on codeigniters site.

however if you feel best to leave it where it is use $_SERVER['DOCUMENT_ROOT'] .'/yourcodeigniterfolderlocation/application/css/style.css' instead.

Sign up to request clarification or add additional context in comments.

Comments

0

You shouldn't keep css in the application folder.It should be outside the application folder.

If you Project name is project then create a folder named css in project and keep all your css there. To access those css you path will be <?php echo base_url().'css/filename.css' ?>

Comments

0

Your CSS file has to be in a public-accessible folder, which is (hopefully) not the case with your application and system folders.

Your assets have to be besides your index.php like so:

- index.php
- css/
    - style.css

Then in your view:

<link rel="stylesheet" href="<?php echo base_url('css/style.css') ?>">

Comments

0

Keeping the Css folder in the root and writing the below code in php page. Solved my issue.

<link rel="stylesheet" href="../../css/style.css" type="text/css" media="all" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.