Html 在p标记中使用div会丢失我的样式

Html 在p标记中使用div会丢失我的样式,html,css,Html,Css,我有一个页面,我想在其中向学生表示一个URL(但没有浏览器默认设置,如更改为鼠标悬停上的指针等),我正在丢失我的样式,因为我将文本包装在div中 index.html: <p> we can see Django made us our first url, the admin. Since this file is our url entry point (as declared in `settings.py`), if our hostname is "www.eat-

我有一个页面,我想在其中向学生表示一个URL(但没有浏览器默认设置,如更改为鼠标悬停上的指针等),我正在丢失我的样式,因为我将文本包装在div中

index.html:

<p>
    we can see Django made us our first url, the admin. Since this file is our url entry point (as declared in `settings.py`), if our hostname is "www.eat-it.com",
    <div style="color:blue;">www.eat-it.com/admin</div> is now available. We'll talk more about Django admin later.
</p>
最近我尝试在div中使用
.fake url

<p>
    we can see Django made us our first url, the admin. Since this file is our url entry point (as declared in `settings.py`), if our hostname is "www.eat-it.com",
    <div class="fake-url;">www.eat-it.com/admin</div> is now available. We'll talk more about Django admin later.
</p>

我建议您使用span而不是div,div是块元素,另一方面span是内联元素,更适合您想要使用它的上下文


正如上面提到的,你有一个额外的;在div的类中

我建议您使用span而不是div,div是块元素,另一方面,span是内联元素,更适合您想要使用它的上下文

<p>
    we can see Django made us our first url, the admin. Since this file is our url entry point (as declared in `settings.py`), if our hostname is "www.eat-it.com",
    <div class="fake-url">www.eat-it.com/admin</div> is now available. We'll talk more about Django admin later.
</p>
正如上面提到的,你有一个额外的;在div的类中


<p>
    we can see Django made us our first url, the admin. Since this file is our url entry point (as declared in `settings.py`), if our hostname is "www.eat-it.com",
    <div class="fake-url">www.eat-it.com/admin</div> is now available. We'll talk more about Django admin later.
</p>
我们可以看到Django为我们创建了第一个url,管理员。由于此文件是我们的url入口点(如“settings.py”中声明的),如果我们的主机名是“www.eat-it.com”, www.eat-it.com/admin现已提供。稍后我们将进一步讨论Django admin。

只需删除
将修复它。


我们可以看到Django为我们创建了第一个url,管理员。由于此文件是我们的url入口点(如“settings.py”中声明的),如果我们的主机名是“www.eat-it.com”,
www.eat-it.com/admin现已提供。稍后我们将进一步讨论Django admin。


只需删除
将修复它。

元素不属于
元素。浏览器通常会对此进行修改,以便在
元素之前关闭
元素,然后在元素之后再次打开。这有效地将段落分成两部分,一部分在
之前,另一部分在
之后


相反,使用一个
,或者更恰当地使用一个提到这一点的
。具体地说,在标记为“标记省略”的部分中,它提到如果一个开头
元素后跟一个开头
元素,则该段落将隐式关闭。
元素不属于
元素。浏览器通常会对此进行修改,以便在
元素之前关闭
元素,然后在元素之后再次打开。这有效地将段落分成两部分,一部分在
之前,另一部分在
之后


相反,使用一个
,或者更恰当地使用一个提到这一点的
。具体地说,在标记为“标记省略”的部分中,它提到如果一个开头
元素后面跟着一个开头
元素,那么该段落就隐式关闭了。

为什么要在
使用中使用
,为什么要使用for link?@NitinDhomse谁说这是一个链接?这是一个假链接。似乎我必须在任何较低的标记(如p、标题等)中使用
span
?我用
span
而不是
div
的基础知识已经有一段时间了,你为什么要在
中使用
使用,你为什么要使用链接?@NitinDhomse说这是一个链接这是一个假链接。似乎我必须在任何较低的标记(如p、标题等)中使用
span
?我用
span
来代替
div
已经有一段时间了,有人知道为什么p中的div会断裂吗?本质的东西gritty@codyc4321正如我所说,这是因为div的默认显示样式,它们应该是“display:block”。另一方面,跨距就像“display:inline”@codyc4321有人知道为什么p中的div会断开吗?本质的东西gritty@codyc4321正如我所说的,这是因为div的默认显示样式,它们应该是“display:block”,另一方面,跨距类似于“display:inline”@codyc4321”,然后不久再次打开。“很抱歉,这种行为在chrome和safari中都没有发生。这可能是误导。看看当有人认为P标签在div之后会自动重新打开时会发生什么:@stormarge因此“通常”。一般情况是:浏览器可以随意处理(或不处理)损坏的HTML。现在还没有一个标准来纠正格式错误的HTML。“然后不久又打开了。”很抱歉,这种行为在chrome和safari中都没有出现。这可能是误导。看看当有人认为P标签在div之后会自动重新打开时会发生什么:@stormarge因此“通常”。一般情况是:浏览器可以随意处理(或不处理)损坏的HTML。没有一个标准来纠正格式错误的HTML。
<p>
    we can see Django made us our first url, the admin. Since this file is our url entry point (as declared in `settings.py`), if our hostname is "www.eat-it.com",
    <div class="fake-url">www.eat-it.com/admin</div> is now available. We'll talk more about Django admin later.
</p>