HTMl 中是否有可用于分组的逻辑容器标签? [英] Is there any logical container tag in HTMl that I can use for grouping?
问题描述
我需要一些在页面中不可见的东西、没有任何边框的东西以及根本不影响页面呈现的东西.我需要这个来大量隐藏或显示里面的东西,比如 document.getElementById("asd").innerHTML = "blah bla blah and some buttons and etc";
我希望它的标签边框不显示在页面上或根本不改变渲染.
例如,我希望渲染结果相同:
asd<输入类型=按钮"值=dsa"/><桌子><tr><td>zxc</td></tr></表>qwe</div>和:
asd<东西 id = "asd"><输入类型=按钮"值=dsa"/><桌子><tr><td>zxc</td></tr></表></某事>qwe</div>div 不好,因为它有边框,并且从 html 页面中的新行渲染.
<html><头><title>asd</title></头><身体>asddsa也变得不可见
解决方案 我对问题的解释:你想在 body
元素内部使用一个 HTML 元素,这样它就可以包含各种元素,包括像表格这样的块元素,以便呈现页面,就好像元素的开始和结束标记不存在一样.也就是说,就好像元素被它的内容替换了一样.特别是,它不应导致任何换行.
HTML 中没有这样的元素.最接近的是 ins
和 del
.它们可能已经足够接近了,因为它们对渲染的唯一默认效果是文本内容分别带有下划线或过度强调(浏览器对块元素内的文本不一致地实现了这一点),并且这些效果很容易被取消,使用通常的 CSS 警告:
ins, del { text-decoration: none;}
之所以有效(并且是有效的 HTML)是因为这些元素具有透明内容模型".例如,一个 ins
元素 可以包含元素出现的上下文中允许的任何内容.
使用这些元素是否合乎逻辑值得商榷,但实际上,ins
(用于插入的内容)甚至可能被认为是合乎逻辑的,这取决于你在做什么.
请注意,某些用户代理或辅助软件可能(至少在将来)以反映其定义含义的方式实现这些元素.例如,语音浏览器可能会在 ins
元素之前和之后说出插入文本"和插入文本结尾".
在某种程度上,a
元素(没有任何属性)的使用方式大致相同(它在浏览器实践和 HTML5 CR 中也具有透明内容模型),但它具有一些限制使这种方法有问题.特别是,根据语法规则,a
元素不得包含另一个 a
元素或其他交互式内容",如 input
.
I need something not visible in page, something that don't have any borders and something that doesn't affect page rendering at all.
I need this for a mass hiding or showing things inside, like document.getElementById("asd").innerHTML = "blah bla blah and some buttons and etc";
I want it's tag borders to not be shown on the page or changed the rendering at all.
For example, I want the rendered result to be same for:
<div>
asd
<input type = "button" value = "dsa" />
<table>
<tr>
<td>zxc</td>
</tr>
</table>
qwe
</div>
and:
<div>
asd
<something id = "asd">
<input type = "button" value = "dsa" />
<table>
<tr>
<td>zxc</td>
</tr>
</table>
</something>
qwe
</div>
The div is bad, because it have a borders and renders from new line in html page.
<html>
<head>
<title>asd</title>
</head>
<body>
asd<div id = "test_div" style = "display: none;">dsa</div>
</body>
</html>
dsa also became invisible
解决方案 My interpretation of the question: You would like to use an HTML element, inside the body
element, so that it can include various elements, including block elements like tables, so that the page is rendered as if the element’s start and end tag were not there. That is, as if the element were replaced by its content. In particular, it should not cause any line break.
There is no such element in HTML. What come closest are ins
and del
. They might come close enough, as their only default effect on rendering is that text content is underlined or overstruck, respectively (browsers implement this inconsistently for text inside block elements), and these effects are easily cancelled out, with the usual CSS caveats:
ins, del { text-decoration: none; }
The reason why this works (and is valid HTML) is that these elements have "transparent content model". E.g., an ins
element may contain anything that would be allowed in the context where the element appears.
Whether it is logical to use such elements is debatable, but in fact, ins
(for inserted content) might even be regarded as logical to use, depending on what you are doing.
Beware that some user agents or assistive software may (at least in future) implement these elements in a manner that reflects their defined meaning. For example, a speech browser might speak "inserted text" and "end of inserted text" before and after an ins
element.
To some extent, the a
element (without any attributes) could be used largely the same way (it, too, has transparent content model in browser practice and in HTML5 CR), but it has some restrictions that make that approach questionable. In particular, by the syntax rules, an a
element must not contain another a
element or other "interactive content" like input
.
这篇关于HTMl 中是否有可用于分组的逻辑容器标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文
相关文章
-
HTMl中是否有可用于分组的逻辑容器标签?;
-
HTML中是否有NO-OP标签?;
-
是否有用于将"td"分组的标签?或"th"标签?;
-
是否有可用于HTML5的xhtml.xsd等效项?;
-
是否有可用于 HTML5 的 xhtml.xsd 等效项?;
-
是否有可用于Delphi的bcrypt实现?;
-
有什么HTML标签用于地址信息?;
-
是否有可用于调整SVG大小的脚本?;
-
如何确定特定标签是否可用于图像;
-
哪个 HTML 标签可用于接受 Orbeon 表单中的动态类名;
-
是否有支持HTML5视频(WebRTC技术)可用于.NET WebBrowser控件?;
-
使用fieldset HTML标签对分组表单有什么意义?;
-
HTML'body'标签是否有onblur事件?;
-
Monster 是否有任何 API 可用于搜索工作;
-
部分标签是否适用于分组表单元素?;
-
有哪些Java库可用于生成HTML5?;
-
是否有Highcharts关于充分标签显示任何可用的选项?;
-
libcurl中是否有可用的压缩;
-
在SharePoint中是否有可用于项目级别权限的Web服务?;
-
是否有替代的XML模式导入器可用于Delphi?;
-
是否有可用于比较模式宏形式的工具/功能?;
-
是否有任何工具可用于TFS签入文件?;
-
STL中是否有分类的容器?;
-
是否有可能从GWT逻辑完全分离HTML / CSS布局?;
-
是否有Delphi标准函数用于转义HTML?;
前端开发最新文章
- 为什么Chrome(在Electron内部)突然重定向到chrome-error:// chromewebdata?;
- 错误102(net :: ERR_CONNECTION_REFUSED):服务器拒绝连接;
- 如何解决'重定向已被CORS策略阻止:没有'Access-Control-Allow-Origin'标题'?;
- 如何处理“Uncaught(in promise)DOMException:play()失败,因为用户没有首先与文档交互。”在桌面上使用Chrome 66?;
- 警告:添加非被动事件侦听器到滚动阻塞'touchstart'事件;
- 如何在浏览器中播放.TS文件(视频/ MP2T媒体类型)?;
- 此请求已被阻止;内容必须通过HTTPS提供;
- 资源解释为样式表,但转换为MIME类型text / html(似乎与web服务器无关);
- 通过HTTPS加载页面但请求不安全的XMLHttpRequest端点;
- 拒绝从执行脚本'*',因为它的MIME类型(“应用/ JSON')不是可执行文件,并严格MIME类型检查被启用。;