HTMl中是否有可用于分组的逻辑容器标签? [英] Is there any logical container tag in HTMl that I can use for grouping?

查看:157
本文介绍了HTMl中是否有可用于分组的逻辑容器标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在页面中看不到的东西,这些东西没有任何边框,并且根本不影响页面渲染。
我需要这个来隐藏或显示内容,比如 document.getElementById(asd)。innerHTML =blah bla blah and some buttons and etc;

我希望它的标记边框不会显示在页面上,或者根本不会改变渲染。



例如,我希望呈现的结果与以下内容相同:

 < div> 
asd
< input type =buttonvalue =dsa/>
< table>
< tr>
< td> zxc< / td>
< / tr>
< / table>
qwe
< / div>

和:

 < DIV> 
asd
< something id =asd>
< input type =buttonvalue =dsa/>
< table>
< tr>
< td> zxc< / td>
< / tr>
< / table>
< / something>
qwe
< / div>

div很糟糕,因为它有一个边框并在html页面中用新行进行渲染。 p>

 < html> 
< head>
< title> asd< / title>

< / head>
< body>
asd< div id =test_divstyle =display:none;> dsa< / div>
< / body>
< / html>

dsa 也变得不可见了

body 元素中使用一个HTML元素,这样它可以包含各种元素,包括像表格这样的块元素,以便页面呈现,就好像元素的开始和结束标记不存在一样。就是说,就好像元素被其内容所取代一样。特别是,它不应该导致任何换行符。



HTML中没有这样的元素。最接近的是 ins del 。它们可能已经足够接近了,因为它们对渲染唯一的默认效果是文本内容分别带有下划线或者过分强调(浏览器对块内容中的文本执行此操作时不一致),并且这些效果很容易被抵消,这是通常的CSS警告:

  ins,del {text-decoration:none; } 

这个工作原理(并且是有效的HTML)是因为这些元素具有透明内容模型。例如, ins 元素可能包含在元素出现的上下文中允许的任何内容。



使用这种元素是否合乎逻辑是有争议的,但在事实上,根据你在做什么, ins (对于插入的内容)甚至可能被认为是符合逻辑的。



<请注意,某些用户代理或辅助软件可能(至少将来)以反映其定义含义的方式实施这些元素。例如,语音浏览器可能会在 ins 元素前后说出插入文本和插入文本结束。



在某种程度上, a 元素(没有任何属性)在很大程度上可以以相同的方式使用(它也具有浏览器实践中的透明内容模型和HTML5 CR),但它有一些限制,使这种方法可疑。特别是,通过语法规则, a 元素不得包含另一个 a 元素或其他交互式内容 输入


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆