[英]HTML: Closing multiple tags with just a single tag
I have a log file that has ANSI colors. 我有一个具有ANSI颜色的日志文件。 I use PHP to str_replace these into
<span color="">
HTML tags. 我使用PHP将它们str_replace到
<span color="">
HTML标记中。
If I use PHP str_replace, and parse color resets as </span>
, how would I end more than one span declaration? 如果使用PHP str_replace,并将颜色重置解析为
</span>
,那么如何结束多个span声明?
Example: <span color="red"><span color="blue"></span>
示例:
<span color="red"><span color="blue"></span>
How could I make it so that one </span>
ends both the previous statements? 我如何才能使
</span>
结束前面的两个语句?
You wouldn't, you need to use two </span></span>
tags to close both <span>
tags. 不需要,您需要使用两个
</span></span>
标签来关闭两个<span>
标签。
For your case this would be 对于您的情况,这将是
<span color="red"><span color="blue"></span></span>
Note: As @calvinf pointed out in a comment below you should use style="color:blue;"
注意: 正如@calvinf在下面的注释中指出的,您应该使用
style="color:blue;"
since the color
attribute has been deprecated for a long time. 由于
color
属性已被弃用很长时间了。
When the browser interprets the <span>
tag, it expects a closing tag for that Exact Same tag. 当浏览器解释
<span>
标签时,它期望该完全相同标签的结束标签。 therefore no matter how many you have open you cannot use a single </span>
because the browser will be desperately searching for the others. 因此,无论您打开了多少,都不能使用单个
</span>
因为浏览器会拼命搜索其他浏览器。
I think there's no way to that. 我认为没有办法。 I think you have to way to do it, First mananualy add the missing "
</span>
" which it's a little ugly Or you could find out why you're missing one 我认为您必须设法做到这一点,首先手动添加缺少的“
</span>
”,这有点难看,或者您可以找出为什么会丢失一个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.