[英]Start tag "a" seen but an element of the same type was already open
I'm new to html, I try to put a link("a"), a text "b", and a link "c" together in the same line.我是 html 的新手,我尝试将链接(“a”)、文本“b”和链接“c”放在同一行中。 Here is my code.
这是我的代码。
<a class = "fixed" href="/a/">linka <span> b </span> <span> <a href="/c/">linkc </a> </span> </a>
But I got some errors, like:但是我遇到了一些错误,例如:
Start tag "a" seen but an element of the same type was already open.
已看到开始标记“a”,但已打开相同类型的元素。 error: End tag "a" violates nesting rules.
错误:结束标记“a”违反了嵌套规则。 error: Stray end tag "span".
错误:杂散结束标记“span”。 error: Stray end tag "a".
错误:偏离结束标记“a”。
I try to get rid of nested, but the linkC would not show up.我试图摆脱嵌套,但 linkC 不会出现。 How to fix this error?
如何修复此错误?
This error ish happening because you have a <a>
tag nested within the first <a>
tag, which is not allowed in HTML .发生此错误是因为您在第一个
<a>
标记中嵌套了一个<a>
标记,这在HTML中是不允许的。 To achieve the layout you're looking for, you can use a different approach that doesn't involve nesting <a>
tags.要实现您正在寻找的布局,您可以使用不涉及嵌套
<a>
标记的不同方法。
One way you could fix this is to use a container element, such as a <div>
, to wrap all the elements together.解决此问题的一种方法是使用容器元素(例如
<div>
)将所有元素包装在一起。
Example:例子:
<div class="fixed"> <a href="/a/">linka</a> <span> b </span> <a href="/c/">linkc </a> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.