<h5>标签验证错误求助:footer标签语法问题排查
Tag Validation Error & Footer Layout
Hey there! Let's get that validation error sorted out and keep your footer stuck to the bottom centered like you want.
First, let's break down the issue in your code:
- The invalid HTML syntax in your
<h5>tag is triggering the validation error. You wrote<h5 class id="footer">— theclassattribute is present but has no value assigned, which isn't allowed in valid HTML. - While not a validation error, using an
<h5>tag for your footer isn't the most semantically correct choice. HTML5 has a dedicated<footer>element for this purpose, which makes your page structure clearer for browsers, screen readers, and search engines.
Solution 1: Fix the
Tag Syntax (Quick Fix)
If you want to keep using the <h5> tag, just remove the unused class attribute. Your corrected HTML will look like this:
<h5 id="footer">© BPA Productions 2018</h5>
Your existing CSS doesn't need any changes here — since you're targeting the #footer ID, the styles will apply exactly as before.
Solution 2: Use Semantic
For better accessibility and semantic markup, swap the <h5> for a <footer> tag. Your HTML becomes:
<footer id="footer">© BPA Productions 2018</footer>
Again, your CSS stays the same because we're still using the #footer ID selector. This fixes the validation error and makes your code more standards-compliant.
Either way, after making this change, the validation error should disappear, and your footer will remain fixed at the bottom center of the page just like you configured it with your CSS.
内容的提问来源于stack exchange,提问作者Brad Anderson

