使用CSS和HTML为不同的段落设置不同的样式 [英] Styling different paragraphs with different styles using CSS and HTML

查看:1123
本文介绍了使用CSS和HTML为不同的段落设置不同的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于在段落标签上使用类标签的问题。我想外部Css文件以某种方式风格的段落,而所有其他段落的默认样式。我做一些谷歌和阅读,发现如果我添加< p class =somename> ; 然后在css文件中,我可以改变该段落使用 p.somename {color:blue;}
但是我发现是 p {color:red;} 似乎会影响他们。

I have a question on using the class tag on paragraph tags. I want the external Css file to style a paragraph a certain way while leaving all the other paragraphs to the default style.I did some googling and reading and found if i add <p class="somename" > then in the css file i can change that paragraph using p.somename{ color: blue;} But what i found is p{color: red;} seems to be affecting them all.

这只是一个示例问题。我遇到的主要问题是我不想要p.somename有一个背景边框。默认< p> 有边框。

This was just a example problem. The main problem im facing is that i dont want p.somename to have a background border.And the default <p> has borders.

推荐答案

在HTML中,

<p id="colorblue">some lorem ipsum here</p>

在CSS中,

 p #colorblue{
color: blue
}

或者tepkenvannkorn的答案将工作。

Or tepkenvannkorn's answer will work.

p.somename { color: blue !important; }

这篇关于使用CSS和HTML为不同的段落设置不同的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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