These validation errors came up after I was correcting my code (putting link to Icon inside head). I believe the problem is combined in my header.php and home.php from the looks of it and from me trying to solve it. The validator also says my <doctype! html> is stray for some reason.

Header.php code:

<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="utf-8">
<title><?php echo $title; ?></title>

<link rel="stylesheet" href="style/stylesheet.css" title="stylesheet">

<link rel="shortcut icon" property='icon' href="img/favicon.ico">

<?php if(isset($pageStyle)) : ?> 
<style type="text/css">
<?php echo $pageStyle; ?>
</style>
<?php endif; ?>
</head>

Home.php code:

<?php 
include("incl/config.php"); 
$title = "Hem";
$pageId = "hem";
$pageStyle = null;
?>

<?php include("incl/header.php"); ?>

<head>
<style>
html {
    background: url("img/church.jpg") no-repeat center center fixed;
    background-size:cover;

}
</style>
</head>

As you can see neither the <head> or doctype seems to be stray. The <style> is inside <head> as you can see as well, and not inside <body>. The reason <style> with background is set in home.php and not in my stylesheet is because I have different images as background for each page on my site. Is it possibly a structure error in this code?

1

There are 1 answers

1
RiggsFolly On

Its best if you are going to open the <head> in an include file to not close it in that include file. Then you have the option to add to your <head>. Then you close it in the main code.

Try this instead

Header.php code:

<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="utf-8">
<title><?php echo $title; ?></title>

<link rel="stylesheet" href="style/stylesheet.css" title="stylesheet">

<link rel="shortcut icon" property='icon' href="img/favicon.ico">

<?php if(isset($pageStyle)) : ?> 
<style type="text/css">
<?php echo $pageStyle; ?>
</style>
<?php endif; ?>

Home.php code:

<?php 
include("incl/config.php"); 
$title = "Hem";
$pageId = "hem";
$pageStyle = null;
?>

<?php include("incl/header.php"); ?>

<style>
html {
    background: url("img/church.jpg") no-repeat center center fixed;
    background-size:cover;

}
</style>
</head>