skip to Main Content

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?

2

Answers


  1. 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.

    Login or Signup to reply.
  2. The title is part of the metadata of the document, so yes, it would be semantically incorrect to put it outside the head:

    4.2.2 The title element

    Contexts in which this element can be used:
    In a head element containing no other title elements.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search