How to use the style tag in part of a text? [duplicate]

-1

I want to do something like this:

<p style="color:red;">Esse texto é vermelho e <style="color:blue;">esse texto é azul</style> mas esse outro continua vermelho</p>

I believe you have understood. I want to get a portion of the text and only change the color of some words, but the rest remains the same.

    
asked by anonymous 03.10.2018 / 04:30

2 answers

4

You can use the <span></span> tag

<p style="color:red;">Esse texto é vermelho e <span style="color:blue;">esse texto é azul</span> mas esse outro continua vermelho</p>

tag <style></style> is for inserting CSS and not a tag tag

<p style="color:red;">Esse texto é vermelho e <span style="color:blue;">esse texto é azul</span> mas esse outro continua vermelho</p>
    
03.10.2018 / 04:35
2

You can use custom tag.

<p style="color:red;">Esse texto é vermelho e <tiosam style="color:blue;">esse texto é azul</tiosam> mas esse outro continua vermelho</p>

If your PC is from the 90's use the tag vovô

<p style="color:red;">Esse texto é vermelho e <vovô style="color:blue;">esse texto é azul</vovô> mas esse outro continua vermelho</p>
  

Just remembering that, besides this comment was IMPORTED, it is worth remembering also that custom elements are still in adoption, and to ensure that they are valid is the case to follow the specification. In principle, they work based on browser tolerance. More details: Custom Elements

Living Standard - Last Updated 19 September 2018 - 4.13 Custom elements

    
03.10.2018 / 05:03