I’m using CodeIgniter and I’m loading a view by doing $this->load->view('index').
My directory looks like this
- application
- assets/css/bootstrap.css
Inside the view (in applications/views/index.php) I’m referencing inside the head tags like this:
<link href="/assets/css/bootstrap.css" rel="stylesheet">
But the controller only loads the elements of html without any styles of Bootstrap css. Am I referencing the wrong way?
You can use the url helper,
site_url()function makes it easy:You can also use the HTML helper and the
link_tag()function:To use the helpers, add these lines in your controller constructor:
Alternatively, you can globally load these helpers in your
application/config/autoload.phpfile. See http://codeigniter.com/user_guide/general/autoloader.html for more information.