Am giving all my css external links inside the head tag.But when I inspect the webpage all css links are appeared inside the body tag instead of displayed in head tag.What am doing wrong?
-
1Show the problem – lkdhruw Jul 01 '17 at 04:21
-
please show some screen shot or error code – Udhay Titus Jul 01 '17 at 04:35
-
I think you've probably got 2 heads. Are you including anything via php? – Doug Jul 01 '17 at 05:58
-
it's easy. check my answer. but if still not solved, please paste your source code of page via browser (Cntrl + U) – Kamarul Anuar Jul 01 '17 at 06:09
-
And also at the second image(inspect),why the empty space is taken after body tag?But i didn't give any space there:( – Uma Jul 01 '17 at 11:08
3 Answers
Fix your quotes and apostrophes.
Because you are using quotes inside href quotes the markup is breaking, causing a browser to guess at proper markup.
You can't use <link href="<?php base_url("foo bar") ?>">
-- All those quotes count as quotes.
Switch to apostrophes for something, such as <link href="<?php base_url('foo bar') ?>">
or <link href='<?php base_url("foo bar") ?>'>

- 21,475
- 8
- 43
- 55
-
I think you are wrong. Why would quotes for a php printed/echoed string have any bearing on the rendered html page? – Doug Jul 01 '17 at 06:01
-
@Doug You are free to test yourself. Heh.. note other answers are *repeating* my answer. – Scott Jul 01 '17 at 06:03
-
Doesn't mean either of you are right. Just equally wrong. His code show's a head is added, with a cloud front script thrown in. The fact he has a head show's he's attempting to add 2 heads. Obviously the second gets ignored and turned into a body. Find where the Cloudfront script is getting added and you'll find the cause. – Doug Jul 01 '17 at 06:08
-
@Doug.. you can **easily** test this yourself you know. *Quotes do matter*. – Scott Jul 01 '17 at 06:55
-
1Of course quotes matter. But quotes in PHP do not affect quotes in html and vise versa. Unless he was printing the entire html markup within his php. Which he is not. Therefore the php is parsed and echoed right where he asks it to, without the quotes... Because that is how it works – Doug Jul 01 '17 at 06:57
Base on screenshot you're provided. There's have a unclosed tag inside your <head></head>
.
Please make sure your HTML tag in head a closed. Contains <link/>
, <script><script/>
, <meta/>
, <style></style>
, <title></title>
and etc.
Base on your screenshot, i would suggest to you, try to edit html tag (especially meta
tag) in your head
<meta whatever="whatever">
to <meta whatever="whatever"/>
<link whatever="whatever">
to <link whatever="whatever"/>

- 312
- 4
- 16
In your base url in links in head you have double quotes ""
because you have double quotes all ready wrapped around it use single quotes inside base_url('')
href="<?php echo base_url("something.css");?>"
change like to single quote in base url
href="<?php echo base_url('something.css');?>"
Make sure you autoload the url helper config/autoload.php
Also make sure you have set your base url in config.php IS A MUST
$config['base_url'] = 'http://localhost/projectname/';
Or a domain some thing like
$config['base_url'] = 'http://www.example.com/';