- Opening tag: It starts with a ‘<‘, followed by an HTML keyword, and ends with a ‘>‘. <html>, <br>, <title> are some examples of HTML opening tags.
- Closing tag: It starts with a ‘</‘, followed by an HTML keyword, and ends with a ‘>‘.</html>, </title> are examples of HTML closing tags.
The below examples illustrate both approaches:
Example 1: The ‘<‘, ‘</’, ‘>’, can be used to identify a word as an HTML tag in a string. The following examples show how to strip out HTML tags using replace() function and a regular expression, which identifies an HTML tag in the input string. A regular expression is a better way to find the HTML tags and remove them easily.
Welcome to GeeksforGeeks.
Example 2: The .textContent property returns the text content of the specified node and all its descendants. The .innerText property do the same thing as .textContent property.
A Computer Science Portal for Geeks