Php – CodeIgniter PHP stylesheet link. HOW

codeigniterPHP

I'm using xampp for my php. And I have download a code igniter and save it on my htdocs. I already made a databasing and a sample page. My only problem is how can I link my css. Where should I save my style.css? How can I call my style.css?

<link rel="stylesheet" href="<? base_url(); ?>stylesheet/style.css" type="text/css" media="screen"/>

I have this but still have a problem. Is there a step by step on how to link a css?

Thank You.

Best Answer

Put your CSS wherever you’d like, then target that url.

Try putting it in the folder ‘/css/test.css’ for instance ‘/’ being the root of your site, not your CI install.

From CI, you can then call it with

<?= link_tag(base_url().'css/test.css'); ?>

That should generate the following code

<link href="http://yoursite.com/css/test.css" rel="stylesheet" type="text/css" />

If you’re having trouble targetin the CSS, the easiest way to find out where your script is trying to call it, is to look in your web pages source output. You’ll see exactly where CI thinks it’s located.