CSS3内联样式,请问怎么把写在CSS文件中的CSS3样式改到html内联中?

html-css012

CSS3内联样式,请问怎么把写在CSS文件中的CSS3样式改到html内联中?,第1张

You’ve written some HTML and now need to style it with CSS. One way is to use inline styles, which is what this article is about.

您已经编写了一些HTML,现在需要使用CSS对其进行样式设置。 一种方法是使用内联样式,这就是本文的目的。

<p style="color: redfont-size: 20px">This is my first paragraph.</p>

Before we jump into the nuances of inline styles—when, why, and how to use them—it’s important to be aware of the other ways to style your HTML. That way, you choose the best option for your code.

在深入介绍内联样式的细微差别(何时,为什么以及如何使用它们)之前,重要的是要知道其他样式化HTML的方式。 这样,您可以为代码选择最佳选项。∵Here’s a summary of your options.

这是您的选择的摘要。

外部样式表 (External Stylesheet)

Developers typically keep all of their CSS in an external stylesheet. In your HTML file, use the <link>element to link to your external stylesheet, which contains your CSS.

开发人员通常将所有CSS保留在外部样式表中。 在HTML文件中,使用<link>元素链接到包含CSS的外部样式表。

1、看下图的代码

2、看看代码显示出来的效果

相信你也已经看出来了,内联是没问题的,但是对于开发者来说是不支持的,因为不好维护,一点点代码是没有问题的,但是当代码很多的时候就不适合了,最好的做法是将css单独放到一个样式文件里,然后将该样式引入进去就行。