CodeIgniter Adding JS and CSS
CodeIgniter use Model-View-Controller (MVC) architecture which work on three-tier architecture all the layers is separate file and folder structure. In CodeIgniter it is recommended that .css and .js file should be placed in CSS and JS folder.
Integrate external css and js file in CodeIgniter, do following steps :
- Now create assets older in your project root directory .
- Create css and js folder inside your assets root directory .
- Copy your .css file in CSS folder and copy .js file in JS folder.
For base_url() function you must load URL helper in your controller’s constructor Or Autoload
//Loading url helper
$this->load->helper('url');
Now you can use base_url() function where link your .css or .js file
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/style.css">
<script type='text/javascript' src="<?php echo base_url(); ?>assets/js/jquery.min.js"></script>
Note : base_url() function print your project base url .In view source it will make complete url.