Solved

Standard extension for a file containing an html fragment?

Posted on 2004-10-05
6
1,242 Views
Last Modified: 2013-11-19
In other words, what do you call a file that has HTML tags in it, but only the tags that would normally appear between <BODY and </BODY. It doesn't have the <HTML <HEAD or <BODY tags?

I was thinking .INC but that is so overused and I would like that to be reserved for ASP code includes. .WAP is almost... .TXT isn't enough.

I spent about 15 minutes searching on the net and on ee specifically, but good keywords seem to be hard to come by: "html fragment" "without <head" "without <html" "html without extension" all came to nothing.

The answer will hopefully allow some sort of functionality in terms of being recognizable (e.g. starts with .H) and official (Microsoft, rfc, netscape, etc... said so).
0
Comment
Question by:JamesNewton
  • 4
6 Comments
 
LVL 11

Expert Comment

by:neester
ID: 12232937
I believe .htm is fine.
There are no "real" standards that I know of...
You could use .tpl (template)....
I would stick with .htm (as opposed to .html) - just so you can see its different, but you can also load the fragment in the browser indivicually without having a forced download (if you use .tpl - most browsers will come up with a download dialogue)...
0
 
LVL 5

Assisted Solution

by:cristy56
cristy56 earned 250 total points
ID: 12233616
You can still name it as .htm , there is no problem with that.

I have tried many times with htm files where there is no <head><body> tag etc, and it can just be a plain text file with a few tags like <font color=xxx> etc and it still works without showing up errors. So I guess u can still name it as .htm


Regards,
Cristy
0
 
LVL 11

Accepted Solution

by:
neester earned 250 total points
ID: 12233919
Christy56

There is no doubt you can name the file whatever you like.
You can call it .exe if you like - the file will be the same, but the browser will not treat it the same.

I am assuming that James will be using a server side language to insert these files into a bigger page...
If that is the case, then it doesnt matter what you name it.
They could be .jpg if you liked.

But you wouldnt be able to view the fragment through your browser.
It would assume it is an image, and give you an error when the HTML is loaded instead of the image.

My recommendation stands at:
.htm for fragment.
and a .html if its a full page.

Purely to differentiate the two files - and also because they both will be interpreted correctly by the browser (for the contents that the files hold).
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12239698
The html extension has nothing to do with whether it is a well-formed and complete document.  the content IS html.  if it is be sued as an include then .inc or .shtml is appropriate, but infact it is a text file and if you give it a .txt extension and send it to a browser, it will still be rendered as html.

Cd&
0
 
LVL 11

Expert Comment

by:neester
ID: 12243463
COBOLdinosaur - but the truth is - there is no real standard here.
.inc is not defined as a HTML fragment...

.txt pages with HTML code SHOULD NOT be rendered HTML.
FireFox doesn't render txt files as HTML.
I just ran a test with the source of this page.

I think James was just looking for some advice on the BEST way to go about it.
I guessed he is using a template system for a website.
And this is the method i have used.
It makes life easier - when looking through folders...

And sometimes a template doenst work, and you can easily load the HTML fragment in the browser still if its a .htm...

THanks for the Grade A James :)
0
 
LVL 11

Expert Comment

by:neester
ID: 12243483
BTW Cd&,
Internet Explorer will not render a .txt with HTML inside it as HTML either.
I just tested it too...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
document.write() deleting all existing HTML 5 50
login jsp example 24 65
Create CSS Animation for Page Transitions 4 38
Help to align the buttons in a row 2 43
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question