How to include html text from another file into an HTML5 page

I have heard about objects, embeds, and even iframes for this purpose. In these options I had formatting issues with the main page style not being applied. Thus, I preferred jQuery and the <article> tag.

So to keep it simple, assign an ID to your article tag,



and load the page using jquery for the article mycustomhtml


$(“#mycustomhtml).load(“customhtml.txt”, function (response, status, xhr) {

if (status == “error”) {

var msg = “Error: “;

alert(msg + xhr.status + ” “ + xhr.statusText);



< /script>

This is as simple as it gets.

I would like to thank Shakeel Abdul Rehman for his help in this snippet.

About these ads

About irtazaali
Project Manager, Application Developer, and Technical Consultant in a wide variety of business applications. Particularly interested in project and product development using C#.NET, ASP.NET, XAML, Visual Basic with datastores like XML, SQL Server, Oracle, and MySQL. Have 15 years experience in commercial software product development. Quite knowledgeable in ROI and infrastructure development operations. Hold MCSD.NET, OCP, and OCA certifications.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 82 other followers

%d bloggers like this: