Help - Search - Members - Calendar
Full Version: <head> issue
HTMLHelp Forums > Web Authoring > Markup (HTML, XHTML, XML)
metalball
hey all,

i have a question. i'm having a weird issue with <head> tag in my site.
the initial code looks like this:

CODE
<head>
<title><?php if(isset($page_title)) echo $page_title; ?></title>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Content-Type" content="text/html;" charset="utf-8" />
<meta name="keywords" content="<?php if(isset($meta_keywords))  echo $meta_keywords; ?>" />
<meta name="description" content="<?php if(isset($meta_description))  echo $meta_description;  ?>" />

<link href="<?php echo base_url() ?>app/css/css/common.css" rel="stylesheet" type="text/css" />
<link href="<?php echo base_url() ?>app/css/css/header.css" rel="stylesheet" type="text/css" />
<link href="<?php echo base_url() ?>app/css/css/st.css" rel="stylesheet" type="text/css" />
<link href="<?php echo base_url() ?>app/css/css/menus.css" rel="stylesheet" type="text/css" />
<link href="<?php echo base_url() ?>app/css/css/icons.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="<?php echo base_url() ?>favicon.ico" type="image/x-icon" />

<script type="text/javascript" src="<?php echo base_url() ?>app/js/prototype.js"></script>
<script type="text/javascript" src="<?php echo base_url() ?>app/js/scriptaculous.js"></script>
<script type="text/javascript" src="<?php echo base_url() ?>app/js/script.js"></script>
<script type="text/javascript" src="<?php echo base_url() ?>app/js/clock.js"></script>
<!--[if IE ]>
<link href="<?php echo base_url() ?>app/css/css/iefix.css" rel="stylesheet" type="text/css" />
<![endif]-->
</head>


while rendered code it looks like this:

CODE
<head>
<title>title</title>
<meta content="no-cache" http-equiv="Pragma"/>
<meta charset="utf-8" content="text/html;" http-equiv="Content-Type"/>
<meta content="keywords" name="keywords"/>
<meta content="description" name="description"/>
</head>
<body dir="rtl">

<link type="text/css" rel="stylesheet" href="http://localhost/rbs/app/css/css/common.css">
</link>
<link type="text/css" rel="stylesheet" href="http://localhost/rbs/app/css/css/header.css">
</link>
<link type="text/css" rel="stylesheet" href="http://localhost/rbs/app/css/css/st.css">
</link>
<link type="text/css" rel="stylesheet" href="http://localhost/rbs/app/css/css/menus.css">
</link>
<link type="text/css" rel="stylesheet" href="http://localhost/rbs/app/css/css/icons.css">
</link>
<link type="image/x-icon" href="http://localhost/rbs/favicon.ico" rel="shortcut icon"/>
<script src="http://localhost/rbs/app/js/prototype.js" type="text/javascript">
</script>
<script src="http://localhost/rbs/app/js/scriptaculous.js" type="text/javascript">
</script>
<script src="http://localhost/rbs/app/js/builder.js" type="text/javascript">
</script>
<script src="http://localhost/rbs/app/js/effects.js" type="text/javascript">
</script>
<script src="http://localhost/rbs/app/js/dragdrop.js" type="text/javascript">
</script>
<script src="http://localhost/rbs/app/js/controls.js" type="text/javascript">
</script>
<script src="http://localhost/rbs/app/js/slider.js" type="text/javascript">
</script>
<script src="http://localhost/rbs/app/js/script.js" type="text/javascript">
</script>
<script src="http://localhost/rbs/app/js/clock.js" type="text/javascript">
</script>
<!--[if IE ]> <link href="app/css/css/iefix.css" rel="stylesheet" type="text/css" /> <![endif]-->
<div class="clsContainer">
</div>
<script type="text/javascript">
</script>
<script type="text/javascript" src="http://www.google-analytics.com/ga.js">
</script>
<script type="text/javascript">
</script>
</body>


as you can see, all of the <link> and <script> elements moved from <head> to <body>.
shifting all of the <link> and <script> elements under <body> tag makes a gap at the top of the page.
how can i make sure that the <link> and <script> elements remain under <head> tag, and not move under <body>?

thanx
Darin McGrew
My guess is that you just need to remove the blank lines.
metalball
QUOTE(Darin McGrew @ Nov 21 2009, 12:26 PM) *

My guess is that you just need to remove the blank lines.

tried that. the problem is not the empty lines, its that the <link> and <script> shifting tags!
how is it possible that they move under <body>??? it makes no sense...
Christian J
I suspect the rendered code is produced by some other PHP script (another file?). For example, this "server code":

CODE
<link href="<?php echo base_url() ?>app/css/css/common.css" rel="stylesheet" type="text/css" />


should not result in this rendered code:

CODE
<link type="text/css" rel="stylesheet" href="http://localhost/rbs/app/css/css/common.css">
</link>

Note how the REL and TYPE attributes show up last in the server code example, but appear first (and in opposite order) in the rendered code. And where does the closing </link> tag come from?

metalball
hey christian
i guess that the direction of tags reverse in rendered mode because of <body dir="rtl">, even that the <body> tag appears after the <head> at the source code.
EDIT: i've reversed the order of <link> structure to:
CODE
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>app/css/css/common.css"  />

and got result:
CODE
...
<body dir="rtl">

<link href="http://localhost/rbs/app/css/css/common.css" type="text/css" rel="stylesheet">
</link>
<link href="http://localhost/rbs/app/css/css/header.css" type="text/css" rel="stylesheet">
</link>
...
so it's definitely the "dir=rtl" changing the order

the <link> closes with </link> because it's showing all of the CSS code under it in the rendered code.
CODE
<link href="http://localhost/rbs/app/css/css/st.css" type="text/css" rel="stylesheet">
1/* CSS Document */
2td{
3 font-family: arial;
...
...
53.dt4 {
54 border-right:none !important;
55 }
</link>

i don't think that PHP has any influence here, because the PHP here only renders values inside tags, and not the tags themselves, or the tags order inside the document.

i'm sorry i can't give link to the project, it's local...
Christian J
QUOTE(metalball @ Nov 21 2009, 01:59 PM) *

hey christian
i guess that the direction of tags reverse in rendered mode because of <body dir="rtl">

No, the DIR attribute only affects text in the browser window, not the source code.

QUOTE

the <link> closes with </link> because it's showing all of the CSS code under it in the rendered code.
CODE
<link href="http://localhost/rbs/app/css/css/st.css" type="text/css" rel="stylesheet">
1/* CSS Document */
2td{
3 font-family: arial;
...
...
53.dt4 {
54 border-right:none !important;
55 }
</link>


You can only use the LINK element for external CSS files. Use the STYLE element for embedded CSS. The question still remains: what added the closing </link> tag?

QUOTE
i don't think that PHP has any influence here, because the PHP here only renders values inside tags, and not the tags themselves, or the tags order inside the document.

True, but you will not get your results from the "initial code" you posted.

Check again that you're not mixing up files, viewing a cached version or similar.
metalball
QUOTE
No, the DIR attribute only affects text in the browser window, not the source code.

yeah, you right, i disabled the "dir=rtl" and still they came up in reverse order... weird...

QUOTE

You can only use the LINK element for external CSS files. Use the STYLE element for embedded CSS. The question still remains: what added the closing </link> tag?

i've checked it with my other projects, all <link> that "wrapping" external file hass the </link> addition at the end of wrap. so it's nothing unusual.

QUOTE

True, but you will not get your results from the "initial code" you posted.

Check again that you're not mixing up files, viewing a cached version or similar.


if i understand correct,
CODE
<meta http-equiv="Pragma" content="no-cache" />
disables the cache...

... wacko.gif


pandy
It hopes to.
metalball
QUOTE(pandy @ Nov 22 2009, 08:30 AM) *

It hopes to.

so am i... tongue.gif
metalball
OK!!!

i think i have a breakthrough...

i believe that encoding of the PHP files got something to do with it...

the original code came with ANSI encoding, and i had to convert them to UTF-8 because using multi language...

i've checked the untranslated pages of my site that had ALL of the files encoded with ANSI, changed some to UTF and the problem appeared!

changing the encoding back to ANSI removes the problem...


so how can i fix this? all of the PHP translation files must be UTF for the translated text...

maybe changing the DOCTYPE or something...?!
metalball
SOLVED!

the document encoding indeed were the problem maker!

after changing the DOCUMENT encoding to ANSI, all fixed!

thanx all for help...
pandy
blink.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.