Search code examples
phphtmlcsscodeigniter

How to refer to css file in codeigniter? 2.0


What is the difference if I store the main.css file in /webroot/myapp/css or /webroot/assets/css?

This one is working...

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

This one does not...

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

Why?


Solution

  • Load the URL helper and then add to your href like so:

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