I'm kind of learning all by myself, and I'm using the W3 validator to check my code. Now I got this document which loads:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="main.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
include("menu.php");
?>
<?php
if (is_file("$file.inc.php")) include ("$file.inc.php");
else include("homepage.inc.php");
?>
</body>
</html>
In the menu you chose for example 'Page A', which then loads as "pageA.inc.php" which contains:
<title>SUPERAWESOME TITLE of page A</title>
text text text
...
It works fine but I get this set of errors in the W3 validator which I don't know how to handle:
If I set a title in the first set of code, to solve the first problem, it always shows me that same title. If I set the tags in te second set of code I get more errors in the W3 validator saying that it doesn't allow it there.
How could I solve this issue? Or shouldn't I care? It's working right now the way it should, I'm just bothered by the errors when validating.
You are writing your title to the body of your html, and this is not valid. The title should be in the head, e.g:
<head>
<!-- other head tags -->
<title>Your Title</title>
</head>
You can do an include also in your head section:
if (is_file("$file.inc.php")) include ("$file.header.inc.php");
And in your inc file just output <title>...</title>
. Then in the body section you can include another file with text output, then your html markup should be valid.
You may try like this You missing end tag
for meta
and you need to add title
inside head
based on the current page
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?php
include("title.php");
?>
<link href="main.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
include("menu.php");
?>
<?php
if (is_file("$file.inc.php")) include ("$file.inc.php");
else include("homepage.inc.php");
?>
</body>
</html>