skip to Main Content

How do I apply both a style for color, such as <span style="color:#c00000"> and a class such as <span class="Bold"> to some text? I’ve tried the example below, but I’m very new to CSS and don’t quite understand yet how to apply both. In my example below, the color shows up but not the bold. Thanks for any help.

<span style="color:#c00000"class="Bold">Some text element</span>

2

Answers


  1. you have it correct but need to add css font_weight:bold to the .Bold class

    .Bold{
    font-weight:bold;
    }
    <span style="color:#c00000"class="Bold">Some text element</span><br>
    <span style="color:#c00000">Some text element</span>
    Login or Signup to reply.
  2. You can write all styles in style attribute by seperating with ;

    <span style="color:#c00000; font-weight:bold;">Some text element</span>
    

    Or you can define a style for a class with css and use it from HTML

    <html>
    <style>
    .myclass {
      color:#c00000;
      font-weight:bold;
    }
    </style>
    <span class="myclass">Some text element</span>
    </html>
    

    And still you can use class and style attributes.

    And maybe you can learn more from W3Schools CSS and W3Schools html classes.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search