I was wondering if there is a HTML element that allows you to incorporate a text file into a HTML document - something ala <pre src="test.txt"\>
?
I realize the question is old, but this is for reference for people that later come to this question. I often use the embed tag. It was introduced in HTML5, and isn't ugly like iframes. You will still need to specify width and height, but I suggest doing so with css.
<embed src="test.txt">
Notice, the embed tag is open ended. The embed tag is supported in all major browsers.
as you said, another file is another document, so you'll have to use something that allows you to display inline documents: the <iframe>
(see wikipedia for more info)
<iframe src="test.txt" height="200" width="200">
Your Browser doesn't support Frames.
</iframe>
if this isn't what you want (frames are... ugly), the other ways to do semething like this is a server-side include or load the document into any element with javascript/ajax (with jQuery, for example).
Most similar is iframe
<iframe src="test.txt" width="100%" height="300">
</iframe>
P/S: Most flexible solution is using JavaScript (How to read from file)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With