如何使用带有ol标签的em标签没有错误? [英] How to use em tag with ol tag without an error?

查看:107
本文介绍了如何使用带有ol标签的em标签没有错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <  !DOCTYPE     html  >  
< html >
< head >
< meta charset = utf-8 / >

< title > 公司页面< / title >
< / head >

< body >
< a > 欢迎使用!您可以在此处找到以下内容:< / a > ;

< em > < ol >
< li > < a href = #logo > 公司徽标< / a > < / em > < / li >

< li > < a href = #people > 员工列表 < / a > < / em > < / li >
< / ol > < / em >

< h1 > 公司徽标< / h1 >
< ; a > 公司使用以下徽标:< / a >

< ul >
< li > Ne w logo:< img src = new_logo.gif alt = 未找到404 / > ; < / li >

< li > 旧徽标:< img src = o ld_logo.gif alt = 404未找到 / > < / li >
< / ul >
< 输入 type = 数字 名称 = name = / > < br / >

< h1 > 员工列表< / h1 >

< 表格 >
< thead >
< tr >
< <跨度cl ass =code-leadattribute> th
> 名字< / th >

< th > 姓氏< / th >
< / tr >
< / thead >
< tbody >


< tr > ;
< td > Mary < / td > ;

< td > Williams < / td >
< / tr >

< tr >
< td > James < / td >

< td > Smith < / td >
< / tr >

< tr > < td > me < / td > < td > < / td > < / tr >

< / tbody >

< / table >
< / table > < a href = google target = 新窗口 > <
div > 点击我< / div > < / a >
< / body >
< / html >





我尝试过:



In第12行,我尝试使用< em>用< ol>但它显示错误。



Quote:

错误:元素ol不允许作为元素em的孩子在这种情况下。 (抑制此子树中的其他错误。)





 <  !DOCTYPE     html  >  
< html < span class =code-keyword>>
< head >
< meta charset = utf-8 / >

< title > 公司页面< / title >
< / head >

< 正文 >
< a > 欢迎!您可以在此处找到以下内容:< / a > ;

< em > < ol >
< li > < a href = #logo > 公司徽标< / a > < / em > < / li >

< li > < a href = #people > 员工列表 < / a > < / em > < / li >
< / ol > < / em >

< h1 > 公司徽标< / h1 >
< ; a > 公司使用以下徽标:< / a >

< ul >
< li > Ne w logo:< img src = new_logo.gif alt = 未找到404 / > ; < / li >

< li > 旧徽标:< img src = o ld_logo.gif alt = 404未找到 / > < / li >
< / ul >
< 输入 type = 数字 名称 = name = / > < br / >

< h1 > 员工列表< / h1 >

< 表格 >
< thead >
< tr >
< <跨度cl ass =code-leadattribute> th
> 名字< / th >

< th > 姓氏< / th >
< / tr >
< / thead >
< tbody >


< tr > ;
< td > Mary < / td > ;

< td > Williams < / td >
< / tr >

< tr >
< td > James < / td >

< td > Smith < / td >
< / tr >

< tr > < td > me < / td > < td > < / td > < / tr >

< / tbody >

< / table >
< / table > < a href = google target = 新窗口 > <
div > 点击我< / div > < / a >
< / body >
< / html >

解决方案

你知道 em 元素是什么吗?



你需要使用的是,你需要设置 em 作为 li 元素。观点是一样的,但是合法的。像这样,

< ol> 
< li>< em>< a href =#logo>公司徽标< / a>< / em>< / li>
< li>< em>< a href =#employees>员工列表< / a>< / em>< / li>
< / ol>

这是您想要使用的。这将呈现您想要的内容。另外,它不会显示错误。



还有一件事,HTML中的每个元素都有一个你需要遵循的语义理论。如果您对元素是否可能是元素的子元素感到困惑,请转到MDN文档并亲自查看,< EM> - HTML | MDN [ ^ ]


<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />

  <title>Company page</title>
</head>

<body>
  <a>Welcome! Here you can find following things:</a>
 
  <em><ol>
    <li><a href="#logo">Company's logo</a></em></li>

    <li><a href="#employees">List of employees</a></em></li>
  </ol></em>

  <h1>Company's logo </h1>
  <a>Company uses following logos:</a>

  <ul>
    <li>New logo:<img src="new_logo.gif" alt="404 Not found" /></li>

    <li>Old logo:<img src="old_logo.gif" alt="404 Not found" /></li> 
  </ul>
    <input type="number" name="name" value=""/><br/>

  <h1>List of employees</h1>

  <table>
    <thead>
      <tr>
        <th>First name</th>

        <th>Last name</th>
      </tr>
    </thead>
    <tbody>
    
   
    <tr>
      <td>Mary</td>

      <td>Williams</td>
    </tr>

    <tr>
      <td>James</td>

      <td>Smith</td>
    </tr>

    <tr><td>me</td><td></td></tr>

      </tbody>
    
  </table>
</table><a href="google" target="new window"><div>click me</div></a>
</body>
</html>



What I have tried:

In line 12, I try to use "<em>" with "<ol>" but it's show an error.

Quote:

Error: Element ol not allowed as child of element em in this context. (Suppressing further errors from this subtree.)



<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />

  <title>Company page</title>
</head>

<body>
  <a>Welcome! Here you can find following things:</a>
 
  <em><ol>
    <li><a href="#logo">Company's logo</a></em></li>

    <li><a href="#employees">List of employees</a></em></li>
  </ol></em>

  <h1>Company's logo </h1>
  <a>Company uses following logos:</a>

  <ul>
    <li>New logo:<img src="new_logo.gif" alt="404 Not found" /></li>

    <li>Old logo:<img src="old_logo.gif" alt="404 Not found" /></li> 
  </ul>
    <input type="number" name="name" value=""/><br/>

  <h1>List of employees</h1>

  <table>
    <thead>
      <tr>
        <th>First name</th>

        <th>Last name</th>
      </tr>
    </thead>
    <tbody>
    
   
    <tr>
      <td>Mary</td>

      <td>Williams</td>
    </tr>

    <tr>
      <td>James</td>

      <td>Smith</td>
    </tr>

    <tr><td>me</td><td></td></tr>

      </tbody>
    
  </table>
</table><a href="google" target="new window"><div>click me</div></a>
</body>
</html>

解决方案

Do you know what an em element is?

What you need to use is, you need to set em as the child for li elements. The view is the same, but is legal. Like this,

<ol>
    <li><em><a href="#logo">Company's logo</a></em></li>
    <li><em><a href="#employees">List of employees</a></em></li>
</ol>

This is what you want to use. This would render what you want it to. Plus, it won't show the errors.

One more thing, every element in HTML has a reason, semantic, that you need to follow. If you ever get confused as to whether an element can be a possible child of an element, go to MDN documentation and see for yourself, <em> - HTML | MDN[^]


这篇关于如何使用带有ol标签的em标签没有错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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