gpt4 book ai didi

html - 样式属性在嵌套段落元素中不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 19:50:08 26 4
gpt4 key购买 nike

在下面的 html 代码中 段落 (p) 元素颜色不随 css 的颜色属性改变 , *

but if i replace p with div element it is working properly..

enter code here

如何在 Ubuntu 14.04 中安装 Node.js 和 npm 工具

如何在Ubuntu 14.04中安装Node.js和npm工具

<div>
<h2>
Introduction:
</h2>
<p style="color:red;">
<h3>Node.js</h3>
&nbsp; &nbsp; &nbsp;
Nodejs is an open source , cross platform , JavaScript runtime environment which is based on <a href="https://developers.google.com/v8/"> Chrome's V8 JavaScript engine</a>.
<br>
Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.<br><br>

It is used to develop scalable, real-time , network and server-side applications written in javascript and we can run that applications within Node.js runtime environment on Mac OS X ,Windows ,Linux ,solaris and BSD.<br><br>

Node.js provides an event-driven architecture and a non-blocking I/O API designed to optimize an application's throughput and scalability for real-time web applications. It uses Google V8 JavaScript engine to execute code, and a large percentage of the basic modules are written in JavaScript. Node.js contains a built-in library to allow applications to act as a web server without software such as Apache HTTP Server, Nginx or IIS.<br><br>

Node.js can be combined with a browser, a document database (such as MongoDB or CouchDB) and JSON for a unified JavaScript development stack.<br><br>

According to wikipedia,

Node.js is used by IBM, Microsoft, Yahoo!, Walmart, LinkedIn, Rakuten, PayPal and GoDaddy .

</p>

<p>
<h3>npm</h3>
&nbsp; &nbsp; &nbsp;

npm is the pre-installed package manager for the Node.js server platform. It is used to install Node.js programs from the npm registry, organizing the installation and management of third-party Node.js programs.
</p>
</div>

**

the output for above code is ** enter image description here


after replacing the first p element in above code with div element


输出是 enter image description here


why color property is not working in p element but worked in div element (in above code)?


最佳答案

<h3>是 block 元素,<p>不能包含 block 元素。当你这样写时:

<p style="...">
<h3>heading</h3>
text
</p>

浏览器不允许 <h3>存在于 <p> 中, 所以它通过关闭 <p> 悄悄修复这个问题尽早标记,产生这样的东西:

<p style="...">
</p><h3>heading</h3>
text

当你使用 <div> 时它工作正常,因为 <div>可以包含其他 block 元素,如 <h3> .

只需移动 <h3><p>之外它应该可以正常工作。

尽管我注意到将所有文本放在一个 <p> 中有点愚蠢并使用 <br><br>分开段落!您可能希望将每个段落放在自己的 <p> 中标签,因为这是“p”的缩写:)

关于html - 样式属性在嵌套段落元素中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33061407/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com