How can I include the CSS file in CodeIgniter? How can I include the CSS file in CodeIgniter? codeigniter codeigniter

How can I include the CSS file in CodeIgniter?


In constant.php:

define('URL','http://localhost/CodeIgniter/');define('IMG',URL.'assets/img/');define('CSS',URL.'assets/css/');define('JS',URL.'assets/js/');

In config.php:

$config['base_url'] = URL;

In view:

<link rel="stylesheet" href="<?php echo(CSS.'bootstrap.min.css'); ?>">

Hope that helps somewhat.


define general css that used. Open "config.php" within directory CodeIgniter\system\application\config.

$config['css'] = 'mystyles.css';

Create a file named mystyles.css within root application: \CodeIgniter.

$this->load->helper('url');       $data['css']        = $this->config->item('css'); 

You can load css in views pages like this.


Add below line in your controller action /application/controllers/yourController.php

$this->load->helper('url');

Then add below line to your view file's head tag.

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

Assuming that you have assets/css/ folder is created in your app directory.

<path to your app folder>/assets/css