为什么我的一些文字的HTML标签段内下跌的&lt之外; P>< / P>在浏览器中时 [英] Why does some of my text within html paragraph tag fall outside of the <p></p>when in browser

查看:108
本文介绍了为什么我的一些文字的HTML标签段内下跌的&lt之外; P>< / P>在浏览器中时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请在下面看到的HTML。在浏览器中查看并因此失去段落的属性时,最后两句属于段落标记之外。
如果您在文本编辑器中查看HTML,你会看到所有的措辞是段落标记内而不是像Firefox和IE浏览器查看时。在查看源代码或调试控制台查看源。

 < HTML和GT;
    < HEAD>
    < META HTTP的当量=Content-Type的CONTENT =text / html的;字符集= UTF-8>
    <标题>测试与LT; /标题>
    <元CONTENT =WIDTH =设备宽度NAME =视口>
    <间的charset =ISO-8859-1>
    <间内容=IE =边缘HTTP的当量=X-UA-Compatible的>
    < /头>
    <身体GT;
    < D​​IV ID =page_body>
     < D​​IV ID =我的内容>
      < D​​IV ID =mymsg级=mymsgcount>
       < D​​IV CLASS =我的菜单>
        < D​​IV CLASS =我-menutext我-menutext1>
                < H1>这是一个测试< / H1>
                &所述p为H.;
                    <内容>确定为什么在本节最后两句话就掉下来在browswer段落标记的:其中; BR>
                        < UL>
                            <李>首先清单项目< /李>
                            <立gt;第二个清单项目< /李>
                            <立GT;第三个列表项目< /李>
                        < / UL>
                        < BR方式>这是第二次最后一句出于某种原因,在浏览器中查看时,属于段落标记之外< BR>
                        <强>最后一句跌出款标签&lt的; / STRONG>
                    < /内容>
                &所述; / P>
        < / DIV>
       < / DIV>
      < / DIV>
     < / DIV>
    < / DIV>
    < /身体GT;
    < / HTML>


解决方案

您的HTML结构被打破了。具体来说,< P> 元素自动如果某些其他元素都遇到过,其中包括终止< UL> 。这意味着,无序列表和一切超越它不是初始段的一部分。

W3C规范说:


  如果p元素立即

一个p元素的结束标记可以被省略
  其次是一个地址,文章,放在一边,块引用,DIV,DL,字段集,
  页脚,表格,H1,H2,H3,H4,H5,H6,头,hgroup,HR,主,资产净值,
  醇,对,pre,节,表或UL,元件,或者如果没有更多的
  在父元素和父元素含量不是一个
  元素。


您可以组这些项目一起< D​​IV>

您可以找到在W3C网站的此处

Please see html below. The last two sentences fall outside of the paragraph tag when viewed in browser and therefore lose the properties of the paragraph. If you look at html in text editor, you will see all verbiage is within paragraph tag but not when viewed in browser like Firefox and IE. Review source in View Source or Debug console.

    <html>
    <head>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>TEST</title>
    <meta content="width=device-width" name="viewport">
    <meta charset="ISO-8859-1">
    <meta content="IE=edge" http-equiv="X-UA-Compatible">
    </head>
    <body>
    <div id="page_body">
     <div id="my-content">
      <div id="mymsg" class="mymsgcount">
       <div class="my-menus">
        <div class="my-menutext my-menutext1">
                <h1>This is a test.</h1>
                <p>
                    <content>Determine why the last two sentences in this section falls out of paragraph tag in browswer:<br>
                        <ul>
                            <li>first list item</li>
                            <li>second list item</li>
                            <li>third list item</li>
                        </ul>
                        <br>This is the second last sentence which for some reason falls outside of the paragraph tag when viewed in browser.<br>
                        <strong>Last sentence to fall out of paragraph tag.</strong>
                    </content>
                </p>
        </div>
       </div>
      </div>
     </div>
    </div>
    </body>
    </html>

解决方案

Your HTML structure is broken. Specifically, the <p> element is automatically terminated if certain other elements are encountered, which includes <ul>. This means that the unordered list and everything beyond it is not part of the initial paragraph.

The W3C specification says:

A p element's end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, div, dl, fieldset, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, nav, ol, p, pre, section, table, or ul, element, or if there is no more content in the parent element and the parent element is not an a element.

You could group these items together with a <div>.

You can find the specific reference on this on the W3C site here

这篇关于为什么我的一些文字的HTML标签段内下跌的&lt之外; P&GT;&LT; / P&gt;在浏览器中时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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