简体   繁体   English

为html中的文本提供默认颜色

[英]Give default color for text in html

How do i give default color for text in html ? 如何为html中的文本提供默认颜色? To explain more in detail...We have dreamweaver or notepad++ or dojo tools or visual studio or any other tool...when we start typing anything..by default it gives color for specified text..Another good example is stack overflow..when some one asks a question...there will be blue color for some text and red for some text and so on... 为了更详细地说明...我们有dreamweaver或notepad ++或dojo工具或Visual Studio或任何其他工具...当我们开始键入任何内容时。默认情况下,它为指定的文本提供颜色。另一个很好的例子是堆栈溢出。 。当有人问一个问题时...某些文本将为蓝色,某些文本将为红色,依此类推...
same like that,i have an web page where when user clicks a button, a message pops up with some html code..so for tags like its should represent one color and content text should be in other color. 同样,我有一个网页,当用户单击一个按钮时,会弹出一条带有html代码的消息。因此,对于诸如其应代表一种颜色而内容文本应为另一种颜色的标记。
hoe do i go about this.? 我这个。

Thanks in advance 提前致谢

Thanks for reply..Currently we have 5 to 10 lines of html code..but in future as per requirement we might have 1000 or more lines of code..so for each tag i nned to css class ? 感谢您的答复。目前,我们有5至10行html代码。但是根据要求,将来我们可能有1000行或更多行代码。

Cascading Style Sheets sound like what you're looking for. 级联样式表听起来像您要找的东西。 You can use CSS to define not only colors, but the entire appearance of your page. 您不仅可以使用CSS定义颜色,还可以定义页面的整体外观。

The most basic CSS selectors are just the names of HTML tags, so you could write a simple stylesheet like this: 最基本的CSS选择器只是HTML标签的名称,因此您可以编写一个简单的样式表,如下所示:

body {
    color: blue;
}

h1 {
    color: red;
}

p {
    color: purple;
}

What you can do is have a master css file and include it in all your html pages. 您可以做的是拥有一个CSS主文件,并将其包含在所有html页面中。 In the master css file you define all your html tags so that they represent what you want the users to see. 在主CSS文件中,定义所有html标记,以便它们表示您希望用户看到的内容。 Once you include the master css file in your html page, it will look same as your other pages. 在html页面中包含主css文件后,该文件将与其他页面相同。 This way you dont need to write css in all the files. 这样,您无需在所有文件中编写CSS。 You will just need to add a link attribute to all your html files. 您只需要向所有html文件添加一个链接属性。

<LINK href="master.css" rel="stylesheet" type="text/css">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM