Last Updated : Jan 1, 2023
As we may face more issues while using #,$,%,&,@, etc. let us solve this problem today.
As, we say that many times we have to include special characters in our html codes and we face issue due to inbuilt interface of html.
- First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
- Secondly, the <html> tag is used to indicate the beginning of an HTML document.
- As above now <head> tag is used to contain information about web page. In this tag a <title> tag is used which helps us to specify a webpage title. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
- Here, then we create a body tag. All the content which we want to show on browser’s screen or display is always written inside this codes.
- Here, as you see in body we use document.write to print the string or say line which we want to print. But here we use encode function which is user defined function and created inside head. Let us understand this first.
- Here, as you can see we convert our special characters to html specific codes. And inside the script we use replaceAll the special characters with regular html expressions. We hope that you understand these lines of codes properly with help of these steps.
- At last, the <body> and <html> tags are closed with </body> and </html> respectively.