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 HTML 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?
如果你粘贴在PHP完成执行后呈现的HTML中(在验证器中)(假设你将标题标签放在正确的位置[在<head></head>
标签中]),这应该可以正确验证)
上一篇: 回复链接,在XHTML Strict中自动添加文本到textarea?
下一篇: 如何使用有效的标记维护动态页面标题?