Techiio-author
Started by Bruce MccullamSep 30, 2021

Open
Remove style tag from HTML tags not inline styling but inside the style tag

5 VIEWES 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 5 VIEWES SHARE

How would I achieve this with something like the preg_replace() function?

1 Replies

Techiio-commentatorErik Lian replied a month ago0 likes0 dislikes

There are some variable methods to remove the style tag from HTML tags, not inline styling, You can use this method for solving your problem:

Method 1: Using CSS remove property: The CSSStyleDeclaration.remove property() method is used to remove a property from a style of an element. The style of the element is selected by going through the styleSheets array and selecting the CSS rule. The removeProperty method can then be specified with the property to be removed.

Syntax:

element.removeProperty('property')

Method 2: Using the setProperty method: The CSSStyleDeclaration.setProperty() method can be used to set the required property of the style. The element of which the property has to be removed is selected and this property is applied to its style property. Setting this property to ‘initial’ resets the property to its initial value, removing any effect of the property.

Syntax:

element.style.setProperty('color', 'initial')

Please go through this link, I think your problem will be solved from this link:

https://www.geeksforgeeks.org/how-to-remove-css-property-using-javascript/#:~:text=Method%201%3A%20Using%20CSS%20removeProperty,array%20and%20selecting%20the%20cssRule.

You must be Logged in to reply
Trending Technologies
15
Software40
DevOps47
Frontend Development24
Backend Development20
Server Administration17
Linux Administration26
Data Center24
Sentry24
Terraform23
Ansible83
Docker70
Penetration Testing16
Kubernetes21
NGINX20
JenkinsX17
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance