-1

i have some code in codeigniter when i try to load css file is not working. how to load css in codeigniter and maybe my code its wrong. can you tell me ho to solve in my code?

<!doctype html>
    <html lang="en">
    <head>
        <meta http-equivn="Content-Type" content="text/html: charset=UTF-8"/>
        <title>Taekwondo</title>
        <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/tkd.css" type="text/css" media="screen">

    </head>
    <body>
        <!--head-->
        <div id="box-wrapper">
            <!--Header-->
            <header>
                <!--top info-->
                <div id="top-info">
                    <div class="row">
                        <div class="twelve column top-desc">
                            <ul>
                                <li><span>Login/Register</span></li>    
                            </ul>
                        </div>
                    </div>
                </div>
                <!--top info end here-->

                <div class="row">
                    <div>
                        <div class="twelve column">
                            <div id="left-header">
                                <!--logo start here-->
                                <div id="logo">
                                    <a href="home.php"><img src="assets/img/logo.png" alt="main-logo" class="retina"></a>
                                </div>
                                <!--logo end here-->
                            </div>
                        </div>
                    </div>
                </div>
            </header>
        </div>
    </body>
    </html>

controller code

<?php
/**
* 
*/
class Home_c extends CI_Controller
{

    function __construct()
    {
        parent::__construct();
    }

    function index()
    {
        $this->load->view('home');
    }
}

?>

and my name css is tkd.css and i save in assets/css/tkd.css

10
  • what is the error you are getting? are you getting wrong path? Commented Feb 9, 2014 at 7:36
  • css is not working.. how to load css in codeigniter? Commented Feb 9, 2014 at 7:38
  • try my answer. If not working, then see your html source and check for css file path. Commented Feb 9, 2014 at 7:39
  • thanks you answer but when i try its not working. i has been check css file path in assets/css/tkd.css Commented Feb 9, 2014 at 7:43
  • No. I'm asking full path. View your source and check the link tag href. Commented Feb 9, 2014 at 7:46

2 Answers 2

0
<?php echo link_tag('css/mystyles.css'); ?>

That snippet will output this HTML:

<link href="css/mystyles.css" rel="stylesheet" type="text/css" />

The function link_tag must be first loaded.

It can be found in HTML_HELPER

CREDITS :Christian Davén

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

Comments

0

As per your comment, I think you didn't load the url helper in application/config/autoload.php file.

$autoload['helper'] = array(('url');

Try this:

<link rel="stylesheet" type="text/css" href="<?php echo base_url("assets/css/tkd.css");">

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.