How to get typed code in output in html?
I have code that I want to insert in the same way inside the html tag and display in the same way.
<body>
<code>
<script>alert("hey!");</script>
</code>
</body>
I have the above and I expect my html output to be as follows. And this code is typed in the output, not executed!
<script>alert("hey!");</script>
CodePudding user response:
You can use special symbols like this
< -> </<
> -> >/>
& -> &
# -> #
( -> (
) -> )
" -> '/"/"
$ -> $
/ -> /
\ -> \
] -> ]
[ -> [
CodePudding user response:
<
script>alert("hey!");<
/script>
Just use <
for the <
at the beginning of a tag.
<body>
<code>
<script>alert("hey!");</script>
</code>
</body>