0

I am new to CI , to test how it works i started by making css file an then a html file, but the problem is that i cannot link my css file to the html one.
This is my html:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="code/application/style/style.css">
<title>Insert title here</title>
</head>
<body>
 Hi
</body>
</html>

This is my css:

body
{
    background-color: black ;
}
1

2 Answers 2

1

Images, css files etc need to reside outside the application folder, preferably in an "assets" folder that is located on the same level. You can then link to them in your views like so:

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

Your folder structure would be:

ci-project
-index.php
-application
-assets
--css // --> style.css
--img // --> logo.png
Sign up to request clarification or add additional context in comments.

5 Comments

See my updated answer. It's a matter of properly structuring your CI-install's subfolders.
It is structured the way you need it to be
In application/config/config.php your base_url should be set as follows: $config['base_url'] = '';
Also, your html files should reside in application/views/, with a .phpextension.
I have copied and pasted $config['base_url'] = ''; and checked if my view was in application/views/ with a .php extension , everything is as you want it to be but its sill not working
0

Maybe ?:

<link rel="stylesheet" href="../code/application/style/style.css">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.