Anam Tahir
Anam Tahir

Reputation: 9

Unable to load css file in codeigniter

I am new to codeigniter and trying to learn it but i am unable to load or use my css stylesheet for layout. The method i followed to load CSS file is what i found on internet but it did not worked. Please suggest something.

Here is my code:

<html>

<head>
<title>homePage</title>

 <!--[if lte IE 6]>
    <style type="text/css">
    img, div { behavior: url(http('<?php echo $base_url; ?>images') }
    </style>
<![endif]-->


<!--[IF lte IE 6]>

<link rel="stylesheet" href="<?php echo $base_url; ?>/css/homestyle.css" type="text/css" />

<![endif]-->
</head>

 <body >


 <div id="page">
 <div id="menulinks">
    <a class="active" href="#"><span>Home</span></a>
    <a href="#"><span>Services</span></a>
    <a href="#"><span>About Us</span></a>
    <a href="#"><span>Contact Us</span></a>
</div>
<div id="header">

</div>
          <div class="active" id="contentarea">
  <br>
 <br> 
 </div>

 </div>
</body>

</html>

Upvotes: 1

Views: 1745

Answers (2)

Jordan Arsenault
Jordan Arsenault

Reputation: 7388

HTML wrapped in <!--[if lte IE 6]> will only be parsed by IE6 and older - which is great for your behavior attribute, but probably to restrictive for homestyle.css. Try this:

 <head>
    <title>homePage</title>
    <base href="<?= $base_url;?>">
    <!--[if lte IE 6]>
        <style type="text/css">
            img, div {
                behavior: url(images);
            }
        </style>
    <![endif]-->
    <link rel="stylesheet" href="css/homestyle.css" type="text/css" />
</head>

Edit after your comments:

Well yea, I assumed you had that variable defined from your question. Head into config/autoload.php and add the 'url' key to the $autoload['helper'] array:

For example: $autoload['helper'] = array('url', 'file', 'your_other_helpers...');

Then change the above HTML to <base href="<?= site_url();?>">

Upvotes: 1

Zefiryn
Zefiryn

Reputation: 2265

<!--[IF lte IE 6]>
<link rel="stylesheet" href="<?php echo $base_url; ?>/css/homestyle.css" type="text/css" />
<![endif]-->

This is a comment and most browsers will not parse what is inside. It is usable only under IE. You need to put <link> outside the comments:

<link rel="stylesheet" href="<?php echo $base_url; ?>/css/homestyle.css" type="text/css" />

Upvotes: 2

Related Questions