Web developer FAQ
Can I email you with a question?
If your question is not already answered in the FAQ, then I would be glad to answer it for you. However, please keep in mind that my time is limited, as is my knowledge, and you may get a faster and more elaborate response from the kind volunteers at All Experts. These people answer questions on a variety of topics, just browse your way to the right category (e.g. HTML) and post your question to an expert in that field.
Update: In fact, I am now one of the volunteers at All Experts and I answer questions in the HTML category. So, if you really want help with a HTML-related question, feel free to post your question to me via that site. The only disadvantage of this method is that, to control my workload, I only accept one question per day — so if I'm already helping one person I won't be able to answer your question immediately.
If you have a question about this FAQ, would like a longer answer or require clarification on a particular topic, then feel free to email me. As before, please remember that I don't have hours to spend answering lots of questions, much as I would like to, so it may be a while before you get a full reply. However, I do read each and every legitimate mail I receive, please just make sure that you use an appropriate title for the subject field otherwise I might think that your email is spam and delete it.
Should I put quotes around attribute values?
It is never incorrect to quote attribute values, so feel free to quote them all if you're not sure. Technically, any attribute values that do not include whitespace (tabs, spaces etc.) do not have to be quoted according to the HTML 4 specification. However, XHTML 1.0 requires all attributes to be quoted and many people, including myself, consider it good style to do so anyway. Quote all attribute values, then you can be sure of standards compliance without producing incorrect code that will not render properly in browsers.
However, if you wish to include quotes as part of the attribute value, for example in alt text, then you must replace these quotes with "
or "
to ensure that they do not terminate the attribute value prematurely. Also, if you are sending HTML output via server-side languages such as PHP, you may have to escape all quotes like so: <img src=\"value\">
.
It doesn't usually matter whether you use single ''
or double ""
quotes, just make sure that you stick to whichever style you choose and don't go changing it halfway through a document! I prefer and recommend using double quotes, but most of the time it's a matter of personal preference.
Should I use lower case or upper case for HTML tags?
According to the current specification, HTML tags are case-insensitive, so it doesn't matter whether you use lower case or upper case. Some people prefer to type all tags in upper case, because it makes them stand out more. Personally, I prefer using lower case because I think it looks more professional and neat, but at the moment you can use whatever method you prefer. You can even mix upper and lower case if you want, although this is not advisable.
However, XHTML and related technologies such as XML are case-sensitive and require you to use lower case for all your tags. Although these standards have yet to become the mainstream language for creating web sites, it's always a good idea to build forward-compatibility into your pages and so I would strongly recommend that you start using lower case for all HTML tags if you don't already. You might think it's a chore now, but you'll be glad you did in the future.
It's also worth mentioning that attributes may or may not be case-sensitive. For example, <ol type="i">
will produce different output to <ol type="I">
, so in this case it does matter what case you use. Also, Unix systems are case-sensitive for filenames and paths, so <a href="index.html">link</a>
is different to <a href="Index.html">link</a>
. Just assume case-sensitivity all the time, work to that principle and everything should work fine.
How do I hide my HTML source code?
You cannot hide the source code to your web pages, all browsers require the full, unencrypted markup to be sent to them in order to correctly render the page. Even if a paricular browser doesn't have the capability to allow you to view the source code, it can still be opened in an external editor.
There are, of course, tricks that you can employ to make it more difficult for users to look at your HTML code, such as removing most of the line breaks to make everything fit on one or two lines. However, although you may make it more difficult to view the source code of your page, it cannot be prevented if the user is determined enough. I advise against deploying such tricks because they can easily be circumvented, and simply make it more difficult for honest users from viewing your source code.
I have also heard recently of some tools coming onto the market that allow you to encrypt your HTML source code so that visitors cannot view it. This is a ridiculous idea, mainly because you would require some sort of plugin to decrypt the data at your end so that your browser could display it. This process would significantly increase the amount of time for your web pages to load. Such a system would also be fundamentally flawed in that after a few weeks someone would figure out the decryption algorithm and you would again be able to access the HTML source code.
It's just not worth the hassle to both yourself and to your visitors to try and hide your HTML code. The Internet is built and run on open standards, instead of spending time and money in vain attempts to circumvent them, you should instead be embracing and utilising the power these standards give you to reach a potential audience of millions of people worldwide.
How do I hide the URL of my page?
It is not possible to hide the URL of your page because your browser requires it in order to display the page properly and make any further requests to the server, e.g. for images. Also, the URL is required if anyone wishes to bookmark your page or tell a friend about it. You would only be making things more difficult for both yourself and your visitors by attempting to mask your URL.
Having said that, it is possible for you to partially obscure URLs, through the use of frames. Why you would want to do this I don't know, since in most browsers it is possible to get the URL of a framed page by right clicking in the frame and choosing the properties option. There's no real benefit to be gained from obscruing URLs, so just leave them as they are.
How do I include comments?
An example of a HTML comment is: <!-- HTML comment -->
. Anything between the <!--
and -->
tags is ignored by the browser, although it will show up in the source code of the page. You can put anything you want inside the comments, except HTML tags and --
, because these may terminate the comment prematurely.
For what screen size should I write?
HTML is not dependant on screen size, so you are not under any obligation from that point to design for a particular size. All modern browsers will wrap most text to fill the screen space available to them, and most will automatically redraw the page if you resize your browser window (NN 4.x is the notable exception to this rule, but it is quickly falling out of circulation).
Preformatted text within <pre></pre>
tags should not exceed 80 characters, as this will cause horizontal scrolling on the majority of graphical browsers. In a similar vein, images over 550 pixels in size will force horizontal scrolling in most browsers with a screen resolution of 640 x 480.
How do I create a link for visitors to send me email?
The following code will create a link that will open your visitors' default mail program with your email address in the To: field: <a href="mailto:me@example.org">email me</a>
. Of course, you should change the me@example.org
to your email address.
N.B. Whilst such a link can be very user-friendly, it is also prone to being harvested by spam-bots that collect email addresses to use on junk-mail lists. You may therefore wish to use a contact form or obscure your email addresses in some way to prevent your address being added to these lists.
How do I define a subject for a mailto link?
You can't, at least not in a reliable, cross-browser, cross-platform way. Allow users to supply their own subjects or use different email addresses for the various subjects you expect to receive email about (i.e. webmaster@domain.com, feedback@domain.com etc.). The other alternative is to create some form of script, using a server-side language such as Perl or PHP, that sends mail to your address using pre-determined or user-specified subjects.
If you must define a subject via a mailto link, then use the following format: <a href="mailto:you@example.org?subject=Hello">email me</a>
. In most modern browsers, this link will launch your email client with a new email addressed to you@example.org
with the subject Hello
. However, this technique will reportedly prevent older browsers from sending mail to you at all, so you'll have to decide for yourself whether or not it's worth the risk.
How can I validate the code that I write?
The W3C has a variety of validators that you can use to check your CSS, HTML, XHTML etc. against the latest (and also older) standards. You can also check the validity of the links within your site, and some of the tools are available for download so that you can run them on your system (which will be much faster and not consume any network resources).