Welcome Guest, Not a member yet? Register   Sign In
Can't get my CSS to show
#1

I've been trying to start building a website for the first time using CodeIgniter, and I can't seem to get my css to load. I've looked on a lot of sites and have tried to find the answer, but none seem to work so far.

Code:
<link href="<?php echo base_url('assets/css/style.css'); ?>" rel="stylesheet">

It directs to the location of the css file but when I press F12 to see the error, it says Error 404 not found.
My css folder is located here:
C:\xampp\htdocs\CI4\assets\css

Any help is appreciated
Thanks.
Reply
#2

(This post was last modified: 03-10-2022, 11:07 AM by ikesela.)

check your xampp setting for DocumentRoot

put asset folder in document root folder
Reply
#3

Try echo base_url(); and ensure the config setting is working as expected.
Reply
#4

(This post was last modified: 03-10-2022, 10:39 PM by startup.)

(03-10-2022, 08:22 AM)Icanopit1 Wrote: I've been trying to start building a website for the first time using CodeIgniter, and I can't seem to get my css to load. I've looked on a lot of sites and have tried to find the answer, but none seem to work so far.

Code:
<link href="<?php echo base_url('assets/css/style.css'); ?>" rel="stylesheet">

It directs to the location of the css file but when I press F12 to see the error, it says Error 404 not found.
My css folder is located here:
C:\xampp\htdocs\CI4\assets\css

Any help is appreciated
Thanks.
1. test echo base_url(); 

2. change below
move folder assets into public

Code:
<link href="<?php echo base_url('public/assets/css/style.css'); ?>" rel="stylesheet">
Reply
#5

Hi,
assuming you are using CI4 and a vhost for your website, whether you use /assets or php echo base_url('assets , your assets folder should be in the "public" folder which is the domain/vhost root, i think it would solve the issue Smile
have a nice day
Reply
#6

ci4
-- app
-- sytem
-- modules
-- public
---- assets
------ css
------ js
------ etc;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

Add

type="text/css"
to your link tag

While this may no longer be necessary in modern browsers the HTML4 specification declared this a required attribute
Reply




Theme © iAndrew 2016 - Forum software by © MyBB