Home > Software engineering >  How can I use 2 different styles in the same p?
How can I use 2 different styles in the same p?

Time:02-03

<p>This is a bold red text</p>

<p color:red,font:bold>This is a bold red text</p>

I tried this way, but not working

How can i fix this prroblem?

CodePudding user response:

You are using style incorrectly, let me show you.

Here are 2 variations on how you can do this.

#1

Correct Style:

<p style="color: red; font-weight: bold;">This is a bold red text </p>

#2

Or you can use classes.

HTML:

<p >This is a bold red text</p>

Style:

.textformatting{
color: red;
font-weight: bold;
}

CodePudding user response:

What you trying do do can sometimes be done like that however adding styling without using a class can be looked down appon. To do what you would like to do woudl be to add a class in the p element then in css type what styesl you would like to be applied.

HTML

<p>This is a bold red text</p>

<p  This is a bold red text</p>

CSS

.text{
    color:red;
    font-weight:bold
}
  • Related