I have 3 HTML files, all in the same Web page: body1.html, body2.html and body3.html
When pointing to body1.html, for 1 particular item, I want a click to go to a particular id in body3.html; and then I want the item in body3.html to redirect to body2.html
In body1.html I have:
<a href="body3.html#3.0">3.0</a>
In body3.html I have:
<a id="3.0" href="body2.html#3.0"> </a>
In body2.html I have:
<a id="3.0">3.0</a>
I would expect this to work but it doesn’t. Clicking in body1.html does go to body3.html, but the redirection to body2.html is not performed.
What am I doing wrong? Is there a way to do what I want using HTML only?
2
Answers
The problem you’re encountering is that the id attribute in HTML is meant to start with a letter (A-Z or a-z) and can be followed by a combination of letters, digits (0-9), hyphens, underscores, colons, and periods. Using numeric values as id attributes goes against the HTML specification.
To achieve the desired behavior, you can modify your code as follows:
By using valid id attributes, the redirection from body3.html to body2.html should work as expected.
Also try playing around code like this and see how it goes.
Do let me know how it works. Thanks.