Okay so I used
<textarea>
BLAH BLAH BLAH CODE
</textarea>
But that didn't work out so well, is there any other code I could use to show my HTML code in a text box?
By the way, it's for a layout site.
Thanks!
Copyright © 2024 Q2A.ES - All rights reserved.
Answers & Comments
Verified answer
you can try the <code> tag or the <pre> tag also,
another option is to "translate" triangle brackets and
quotes to special characters. (those with ampersand)
I had this html tag in my html file: <hr style="text-align: center; width:100%; color:blue"> Replaced the first character, the "less than sign", with the following four letters (I can't type the characters next to each other, or it's converted back to the less than sign, since this answer box is composed of HTML too): & l t ; The actual hr code displayed on the web page correctly (when displayed on the web page, the four letters are converted back to a "less than sign"): Great question!
You can use the <textarea> code, but you have to put it in a form, like this:
<FORM>
<TEXTAREA COLS="30" ROWS="5">
ALL TEXT GOES HERE
</TEXTAREA>
</FORM>
You can change the columns (cols) or width to whatever suits your design, and the same goes for the rows, or height.
If you need to display only and not to edit you can use div tag. It can have scroll bar also.
<div>hello</div>
You can set many features of div like width, height, scroll, border color...
here is a simple div scroll box that i have given you, you can change the width and height, background color (at the moment it is transparent) text color where it says COLOR HERE, and then place your HTML code where it says PLACE CODE HERE...
<div style="width: 200px; height: 200px; background-color: transparent; color: COLOR HERE; text-align: center; overflow: auto; padding: 4px;">PLACE CODE HERE</div>