Search code examples
htmltitlehead

Is it considered bad to put the <title> tag outside the <head> tag?


Is it considered bad to put the <title> tag outside the <head> tag? I'm using PHP and I only know the page name after loading the header.php file where <head> is located. Would placing the <title> tag later in the page influence SEO or cause any other browser related problems or would you advice against it?


Solution

  • Yes the title tag should only be used in the head.

    So I'm guessing your header.php has a line like this:

    <title><?php echo $title ?></title>
    

    And on your pages you have an include('pathtofile/header.php'); Just define $title before the include line.

    Example:

    $title = "This is my page title";
    include("includes/header.php");
    

    Or if it isn't structured like that you may want to change it up a bit.