How to remove tags from a text in html but keep the attributes in the text

0

I want to remove the html tags but keep the format that the tags generate in the text.

I'm using the strip_tags() function that removes the html tags but it does not leave the format ..

For example I have this text in html:

<font color="#ff0000">ZONA 1</font>;

I removed the tags but the text ZONE 1 does not keep the color red ff0000

    
asked by Ziul̺̿i̺̿n̺̿g̺̿ Maca̶yo 23.08.2017 в 04:42
source

1 answer

3

The text itself is not formatted, the format is specified by some marking, for example, in html <strong> hola </strong> , the label is the one that gives semantic meaning to a text in bold, the browser interprets that the text should be in bold, so when rendering the text, choose the correct typography and modifications.

You can not delete html tags without losing format , since they are yourself. My advice is that you use a different markup language, which you must convert to html (a kind of SandBox)

For example here in stackoverflow, use Markdown

The links are written as: [texto](https://enlace)
and are displayed as: text

The italics are written as: *cursiva*
and they are displayed as: italic

The titles are written as: #Título

and are displayed as:

Title

In general, there are hundreds of languages intended to format the text, some very general ones such as BBCode , Markdown , rtf , < a href="https://en.wikipedia.org/wiki/TeX"> TeX

    
answered by 23.08.2017 / 05:02
source