没有P元素,只有一个结束标签



我是编程新手,最近刚开始使用HTML,当我试图创建一个示例网站并在验证器上检查它时。w3c给了我上面的错误,我很确定所有的开始和结束标签都是完全相同的计数,请有人帮助我,下面是我做的代码。

<!DOCTYPE html>
<html lang="en">
<title>Pizza</title>
<p><h1>My Favorite Pizza</h1></p>
<p><h2>What is <em>Pizza</em>?</h2><a href="https://en.wikipedia.org/wiki/Pizza"></a>
<p>a dish of Italian origin, consisting of a flat round base of dough baked with a topping of tomatoes and cheese, typically with added meat, fish, or vegetables.</p>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a3/Eq_it-na_pizza-margherita_sep2005_sml.jpg/330px-Eq_it-na_pizza-margherita_sep2005_sml.jpg" alt="Pizza">
<p><h3>What are the types of Pizza?</h3></p>
<ol>
<li>Neapolitan Pizza.
<li>Chicago Pizza.
<li>New York-Style Pizza.
<li> Sicilian Pizza.
<li> Greek Pizza.
<li>California Pizza.
<li>Detroit Pizza.
<li>St. Louis Pizza.
</ol>
<p><h3>examples of Pizza types</h3></p>
<img src="https://image.shutterstock.com/image-photo/pizza-cheese-seafood-260nw-1099161842.jpg" alt="Meat Pizza">
<img src="https://image.shutterstock.com/image-photo/pizza-ham-mozzarella-tomatoes-radicchio-260nw-1085673227.jpg" alt="Vegetables Pizza">
<img src="https://image.shutterstock.com/image-photo/supreme-pizza-pepperoni-mushrooms-mozzarella-600w-1918786631.jpg" alt="Pepperoni Pizza">
<p><h4>Common Places that sells pizza</h4></p>
<p><a href= https://www.instagram.com/pizzastation.eg/>Pizza Station</a></p>
<p><a href="https://www.egypt.pizzahut.me/en/home">Pizza Hut</a></p>
<p><a href="https://www.dominos.com.eg/">Domions Pizza</a></p>
<p><a href="https://www.papajohnsegypt.com/">Papa Johns</a></p>
</body>

Also I made this on my own computer how can I have someone else able to view it?

试试下面的代码。我已经格式化并修正了你的错误。

<!DOCTYPE html>
<html lang="en">
<head>
<title>Pizza</title>
</head>
<body>
<h1>My Favorite Pizza</h1>
<h2>What is <em>Pizza</em>?</h2>
<a href="https://en.wikipedia.org/wiki/Pizza"></a>
<p>
a dish of Italian origin, consisting of a flat round base of dough baked
with a topping of tomatoes and cheese, typically with added meat, fish, or
vegetables.
</p>
<img
src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a3/Eq_it-na_pizza-margherita_sep2005_sml.jpg/330px-Eq_it-na_pizza-margherita_sep2005_sml.jpg"
alt="Pizza"
/>
<h3>What are the types of Pizza?</h3>
<ol>
<li>Neapolitan Pizza.</li>
<li>Chicago Pizza.</li>
<li>New York-Style Pizza.</li>
<li>Sicilian Pizza.</li>
<li>Greek Pizza.</li>
<li>California Pizza.</li>
<li>Detroit Pizza.</li>
<li>St. Louis Pizza.</li>
</ol>
<h3>examples of Pizza types</h3>
<img
src="https://image.shutterstock.com/image-photo/pizza-cheese-seafood-260nw-1099161842.jpg"
alt="Meat Pizza"
/>
<img
src="https://image.shutterstock.com/image-photo/pizza-ham-mozzarella-tomatoes-radicchio-260nw-1085673227.jpg"
alt="Vegetables Pizza"
/>
<img
src="https://image.shutterstock.com/image-photo/supreme-pizza-pepperoni-mushrooms-mozzarella-600w-1918786631.jpg"
alt="Pepperoni Pizza"
/>
<h4>Common Places that sells pizza</h4>
<p><a href="https://www.instagram.com/pizzastation.eg">Pizza Station</a></p>
<p><a href="https://www.egypt.pizzahut.me/en/home">Pizza Hut</a></p>
<p><a href="https://www.dominos.com.eg/">Domions Pizza</a></p>
<p><a href="https://www.papajohnsegypt.com/">Papa Johns</a></p>
</body>
</html>
<!-- Also I made this on my own computer how can I have someone else able to view it? -->

你的代码中的错误和我如何修复它们:

  1. 你的标题标签(h1, h2等)不应该嵌套在<p>标签内。在HTML中,<p>意味着段落,并且会使字体大小为16px,这是你不希望在标题中出现的。我已经从所有的标题中删除了<p>标签,因为它们不应该在那里。
  2. 在第24行,您有以下代码:<p><a href= https://www.instagram.com/pizzastation.eg/>Pizza Station</a></p>。由于您忘记将URL放在引号中,因此它被认为是一个自结束标记,因为它具有以下格式:<tag />(后面带有/的普通标记),这就是自结束标记的外观。这里有一些例子:<br />,<meta />。我在url周围添加了引号,这样它就像一个普通的锚标记。
  3. 我把<title>放在<head>标签内。头部标签应该包含以下标签(如果你正在使用它们),并不是所有这些都是强制性的):<link>,<title>,<meta>,<style>,<script>等。

为了让别人看到你的网站,你需要把它发布到一个网络主机上。InfinityFree是一个不错的选择,但对于你的第一个网站来说,它可能有点复杂。我推荐W3Schools Spaces。

祝你进一步学习HTML好运,你已经有了很好的开始,并且做得很好:)

<p><h2>What is <em>Pizza</em>?</h2><a href="https://en.wikipedia.org/wiki/Pizza"></a>

这里没有关闭

标签。在结尾关闭

相关内容

  • 没有找到相关文章

最新更新