How to maintain a dynamic page title with valid markup?
Currently in my code I have something like this outside of the HTML head tag:
<title>My Website - <?php echo $row['title']; ?></title>
This works but does not validate with w3 because with XHTML titles can only be modified within the H开发者_开发百科TML head tag.
How does one solve this? I want to maintain 100% valid XHTML Strict markup which I currently have but I don't want to use any messy hacks either. I read that changing the website title with Javascript after the page loads is bad practice but it seems like the only viable option here. What does SO think?
This should validate correctly if you paste in the HTML(in the validator) that is rendered after the PHP is done executing (assuming you put the title tag in the right position[aka in the <head></head>
tags])
精彩评论