6

I'd like know if having the title tag positioned at the end of <head> tag or in any other position, always inside the <head></head>, can lead to some kind of problem, I'm not talking about SEO stuffs, I'm talking about standards, browser rules, web application rules, or something like this.

I'd like to load a page from two different php file like this, is it a wrong way?

<!-- file1.php -->
<html>
<head> 
....

<!-- file2.php -->
<title><?php echo($var)?>
</head> 
<body>
...

<head> tag is not closed, because with the second file I dynamically add the <title> tag.

3 Answers 3

4

As for SEO it doesn't matter where in between the head tag the title tag is located. It's only rendered in the browser title bar. Google will change it occasionally if they feel they can build a better title than your page has for someone running a related search. There's not affect though on your website rankings based on the position of the title tag in the header. You can load as many files before and after it. Some examples are dynamically loaded CSS and JS files.

4

Browsers (and search engines) do not see PHP code. They only get the HTML document that has been produced by PHP software and sent by the server. So it does not matter how the content was originally divided between PHP files.

Similarly, all HTML specifications relate to the resulting HTML document, not to the tools used to generate it.

Within an HTML document, the title element may appear anywhere inside the head element. (In your example, it is the only element there.) I haven’t seen any reasons to expect that its placement there matters anything, though it is normal to put it before any other elements there except a meta element that declares the character encoding (since that declaration should appear as early as possible).

1
  • thanks the information about character encoding position is really usefull, as I reach 15 point I'll point up this answer.
    – webose
    Nov 6, 2012 at 23:14
0

The <title> element is required and it doesn't matter where it is put in the <head> section as long as it is beneath the character encoding declaration (i.e. <meta charset='utf-8'>). The character encoding declaration should always be the first element of the head section.

Furthermore, I will also say that <head> tags are optional, and so are <body> tags. It is safe to omit these tags from the HTML generated by PHP, as the browser will automatically know where these sections of the document start.

HTML5 specification on the title element: http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-title-element

1

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.