我应该使用什么标签来代替 html 中不推荐使用的标签字体(不能使用 CSS)
这个问题可能会造成误解:我知道我必须使用 CSS 来成功验证我的文档是否为 XHTML 1.0 Transitional。 事实是,我必须在网页中嵌入一张由 0 和 1 创建的图片 text image,问题是代码使用了已弃用的标签字体,看起来像这样
<!-- IMAGE BEGINS HERE -->
<pre>
<font size="-3">
<font color="#000000">0001100000101101100011</font>
<font color="#010000">00</font>
<font color="#020101">0</font>
<font color="#040101">0</font>
<font color="#461919">1</font>
<font color="#b54f4f">1</font>
...etc.etc...
</font>
</pre>
<!-- IMAGE ENDS HERE -->
(在这个代码示例中,我在每对标签后面插入了一个换行符以使其更具可读性,但原始代码是由于
标签,所有内容都在一行中)。
字体的颜色至少改变了数千次,所以我从未考虑过在 CSS 中为每个组合创建一个字段。希望有人至少知道在哪里可以找到解决方案,我到处搜索:)
谢谢
this question can create a misunderstanding: I know I have to use CSS to validate successfully my document as XHTML 1.0 Transitional. The fact is that I have to embed in my webpage a picture composed by zeros and ones created with text image, and the problem is that the code uses deprecated tag font and looks like this
<!-- IMAGE BEGINS HERE -->
<pre>
<font size="-3">
<font color="#000000">0001100000101101100011</font>
<font color="#010000">00</font>
<font color="#020101">0</font>
<font color="#040101">0</font>
<font color="#461919">1</font>
<font color="#b54f4f">1</font>
...etc.etc...
</font>
</pre>
<!-- IMAGE ENDS HERE -->
(In this code example I inserted a newline after each couple of tags to make it more readable, but the original code is all in one line because of the <pre>
tag).
The font's color changes at least thousands times so I never considered to create a field in the CSS for each combination.Hope someone knows at least where to find a solution, I searched everywhere :)
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以将
0001100000101101100011
替换为
0001100000101101100011
等...
*编辑:我知道这是 CSS,但它不涉及像问题所述的单独样式表,这可能没问题。
You could replace
<font color="#000000">0001100000101101100011</font>
with
<span style="color:#000000">0001100000101101100011</span>
etc...
*Edit: I know this is CSS, but it doesn't involve a separate stylesheet like the question states, which may be ok.
那么 JavaScript 呢?
将颜色数据作为 JSON 数组发送,将“0”和“1”作为另一个数组发送,并动态生成 DOM 元素。
或者像这样的东西...
What about javascript ?
Send the color data as a JSON array, the '0' and '1' as another array and dynamically generate the DOM elements.
Or something like this...
多谢! :DI使用了这段代码
它工作正常! :D
Thanks a lot! :D I used this code
It works correctly! :D
为什么需要验证?
您已经获得的解决方案对于您正在做的事情来说绝对没问题。 有用。 这不是一个有意义的文档,应该使用语义标签来标记以提高可访问性; 这是一件艺术品,所以如果它可以帮助您更清楚地表达您的意图,请随意忽略规则。
如果验证是您尝试做出的艺术陈述的一部分,请按照其他海报的建议使用
00
- 但是这会大大增加你的文件大小。另一种方法是更改文档类型,这样您就不会针对 XHTML Transitional - 使用
或某些相反,较早的 HTML 修订版。
Why does it need to validate?
The solution you've already got is absolutely fine for what you're doing. It works. This is not a meaningful document that should be marked up with semantic tags for improved accessibility; it's a work of art, so feel free to ignore the rules if it helps you express your intentions more clearly.
If validation is part of the artistic statement you're trying to make, then use
<span style="color:#ff00ff;">00</span>
as suggested by other posters - but that'll increase your file size considerably.Another approach is just to change the doctype so you're not targetting XHTML Transitional - use
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
or some earlier HTML revision instead.