Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

making a paragraph in html contain a text from a file

Tags:

html

I have an html paragraph (inside a div) in which I want to display a simple fixed text. The text is a bit long so I'd rather the text will be in a seperate txt file.
something like

<div><p txt=file.txt></p></div> 

Can I do something like that?

like image 331
Boaz Avatar asked Jun 14 '11 18:06

Boaz


People also ask

How do you create a paragraph in HTML?

To add a new paragraph in HTML, place your insertion mark cursor into the HTML document where you want to add the new paragraph. Then type the paragraph start tag: <p>. Then type the paragraph's text. At the end of the new paragraph's text, type the end tag: </p>.

Can HTML read a text file?

HTML 5 provides a standard way to interact with local files with the help of File API. The File API allows interaction with single, multiple as well as BLOB files. The FileReader API can be used to read a file asynchronously in collaboration with JavaScript event handling.


1 Answers

You can do something like that in pure html using an <object> tag:
<div><object data="file.txt"></object></div>

This method has some limitations though, like, it won't fit size of the block to the content - you have to specify width and height manually. And styles won't be applied to the text.

like image 155
Klesun Avatar answered Oct 06 '22 05:10

Klesun