How to change font color using html?

I am creating a webpage where I want the font color to be red in the paragraph, but I'm not sure how to do this.

I used FrontPage to create web pages before this HTML material was completely new to me. What is the best way to do this?

+3
source share
4 answers
<p style="color:red">Foo</p>

Or preferred:

<p class="error">Foo</p>

Where the "error" is defined in your stylesheet:

.error {
    color: red;
}
+13
source

The preferred way to use this is Cascading Style Sheets (CSS) . This allows you to edit the visual aspects of the site without having to deal with the HTML code itself.

Explanation:

<[tag] style="[css]"> Content </[tag]>

[] . , "p" (), "span", "div", "ul", "li" ..

[css] - CSS. , ": , : 15 , -: "


html - "" (, ), "id" , .

:

<[tag] id="element1" class="red"> Content </[tag]>
<[tag] id="element2" class="red"> Content </[tag]>

- html. id - - , .

CSS ( ):

<style type="text/css">

.red {
    color:red;
}

#element1 {
    background-color:black;
}

</style>

, "". class= "" - , . CSS , (), . , class= "error" class= "hilight" . ( , )


CSS:

, , CSS, , :

CSS

, , CSS . , , CSS, :

<style type="text/css"> <!-- Your CSS here --> </style>

CSS, . " " , :

<link href="file.css" media="all" rel="stylesheet" type="text/css"/> 

file.css - , .

"link" , CSS. , 10 HTML, , CSS.

CSS . , , CSS-, :

<[tag] style="<!-- CSS HERE -->"> Content </[tag]>

CSS

CSS, , , . , , , .

CSS, , , :

, div "basic", , , .

"" :

.[identifier] { }

, ".". , "", :

.basic { }

, , "basic", , "div". :

[html-tag].[identifier] { }

, :

div.basic { }

"div" "body". , . :

div.basic {
    background-color:black;
    color:white;
    border:1px solid gray;
}

"div", "" .

, , "id" , , , , "id"

#unique-basic {
    background-color:black;
    color:white;
    border:1px solid gray;
}

CSS : http://www.w3schools.com/css/

:

HTML- CSS , . CSS , .

+6
<p style="color:red">Your Text here</p>

But, like others, now they say more and more words: even better than the above would be to use classes or identifiers and assign CSS attributes to them instead of using the inline style.

0
source
<style type="text/css">
.myCSS
{
     color:red
}
</style>

<div class="myCSS">text</div>
<span class="myCSS">text</span>
<p class="myCSS">text</p>

<!--  table elements..... -->
<td class="myCSS">text</td>
<tr class="myCSS">text</tr>
0
source

Source: https://habr.com/ru/post/1713160/


All Articles