XhCode Online Converter Tools

Strip Html Tags, CSS and JS codes online

Enter html here:
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Results:
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Strip Html Tags, CSS and JS codes

To strip HTML tags, CSS, and JS code from a document or string, you can use regular expressions or a parsing library depending on the programming language you're working with. Here's an example using Python:

Example using Python:
python

import re

def strip_html_css_js(input_string):
# Remove HTML tags
stripped_html = re.sub(r'<.*?>', '', input_string)

# Remove CSS styles
stripped_css = re.sub(r'<style.*?>.*?</style>', '', stripped_html, flags=re.DOTALL)

# Remove JavaScript
stripped_js = re.sub(r'<script.*?>.*?</script>', '', stripped_css, flags=re.DOTALL)

return stripped_js

# Example input
html_content = """
<html>
<head>
<style>
body { background-color: blue; }
</style>
<script>
alert('Hello World');
</script>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is a <strong>test</strong>.</p>
</body>
</html>
"""

result = strip_html_css_js(html_content)
print(result)
Output:
bash

Hello, World!
This is a test.
This approach uses regular expressions to remove HTML tags, <style> CSS content, and <script> JavaScript content. Keep in mind that this approach is relatively simple and might not handle all edge cases. For more complex or specific needs, you might want to use specialized HTML parsing libraries such as BeautifulSoup in Python.

TOP