-2

I'm using html and css to create a site . the problem I am encountering is that I tyed the code to modify the color of some part in my text but when I open the doc in the browser the code does not have effect on the text. Can someone please check what I'm doing wrong ?

<p>
<strong> 
<span class="titreengras">Company description </span> 
</strong>
<br> Production description or service description ( we have both in the case of this business) In this section you talk about the offerings that you will establish for the people. what you will have available for your customers. Meaning you have to describe the product ( the hub ...what it means ...how it comes ..it locations ...its quality) and then the service ( establishment of cloud-based offices inter-related...certificationsand patents)
</br>
</p>

3
  • 2
    You haven't posted any code that have anything to do with changing the color of text.
    – Dai
    Jun 25, 2020 at 20:04
  • Where are you trying to modify color here? I see a class, but I see no style rules anywhere.
    – David
    Jun 25, 2020 at 20:04
  • FYI: <p/> should be </p>. You should also add the styles to the post Jun 25, 2020 at 21:48

4 Answers 4

1

Well, you need to create a class in the style tag of your html page, like that snippet in the example.

.titreengras {
  color: red;
}
<p>
  <strong> 
    <span class="titreengras">Company description </span>     </strong>
  <br> 
    Production description or service description ( we have both in the case of this business) In this section you talk about the offerings that you will establish for the people
      . what you will have available for your customers. Meaning you have to describe the product ( the hub ...what it means ...how it comes ..it locations ...its quality) and then the service ( establishment of cloud-based offices inter-related...certifications
      and patents)
<p/>

If you want to know more and study some stuff the https://www.w3schools.com/ is a nice start.

0
1

To get it to work you will need three things:

  1. Give a class to your html tag.
<span class="titreengras">Company description </span>
  1. Create a css file with your styling. Ex.: styles.css
.titreengras {
    color: #41b230; // sets the color to any given hex value.
}
  1. You need to import your css file into the html file you were working on before. Do it by linking your stylesheet inside the header of your html file. It should look something like this:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>File title</title>

    <link rel="stylesheet" type="text/css" href="style.css" />
  </head>
  <body>

<!--- rest of the html file... -->

Where <link rel="stylesheet" type="text/css" href="style.css" /> is the line you need to insert on your head and style.css is the path for your css file.

2
  • this is the exact method I want to use . but it is not working for me . should I add on the css file : // set the color to any given hex file ...or it is just a comment Jun 28, 2020 at 15:26
  • @HarauldYmerAdjovi it was just a comment Jul 5, 2020 at 19:39
0

You probably forgot to add your .css file between your header tag in index.html but here is the fixed snippet

<style>
.titreengras{
color: green;}
</style>
<p>
<strong> 
<span class="titreengras">Company description </span> 
</strong>
<br> Production description or service description ( we have both in the case of this business) In this section you talk about the offerings that you will establish for the people. what you will have available for your customers. Meaning you have to describe the product ( the hub ...what it means ...how it comes ..it locations ...its quality) and then the service ( establishment of cloud-based offices inter-related...certificationsand patents)
</br>
</p>

4
  • 1
    your answer is the most accurate Jun 28, 2020 at 15:18
  • but in this case I do not need to attach any css file, do I ? Jun 28, 2020 at 15:21
  • I mean I believe this is directly in the html file Jun 28, 2020 at 15:22
  • well, in this case you just put it in the html file but it's a REALLY good pratctice to decouple the css (style) and the html. I recommand you to put your style in the .css file then add a reference to this css into your index.html between the headers. Jun 28, 2020 at 23:30
-2

You can add styles directly by add style='color: yellow' in particular tag or add styles in CSS style sheet. Make sure your CSS style sheet is linked properly by placing link rel="stylesheet" type="text/css" href="css/style.css" in Html file.

If styles still not working, clean browsing data.

 <p>
   <strong>
    <span class='myClass' style='color: yellow'>Company description </span>
   </strong><br> Production description or service description ( we have both 
 in the case of this business) In this section you talk about the offerings 
 that you will establish for the people
 . what you will have available for your customers. Meaning you have to 
 describe the product ( the hub ...what it means ...how it comes ..it 
 locations ...its quality) and then the service ( establishment of cloud- 
 based offices inter-related...certifications
  and patents)
 </p>

  CSS FILE:
    myClass{
     color: yellow;
    }
1
  • you should have at least taken the time to look at the OP code. The trailing <p/>is not valid and it is not adjusted in your answer Jun 25, 2020 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.