HTML Interview Questions (2)
There are many things that you can do ahead of time to prepare for the
interviewing process, and move yourself a step above of the competition.
Updating your resume and reviewing frequently asked interview questions can be
very effective, and goes a long way in getting the most out of your interview.
How do I remove the border around frames?
Removing the border around frames involves both not drawing the frame
borders and eliminating the space between the frames. The most widely
supported way to display borderless frames is <FRAMESET ... BORDER=0
FRAMEBORDER=0 FRAMESPACING=0>.
Note that these attributes are proprietary and not part of the HTML 4.01
specifications. (HTML 4.01 does define the FRAMEBORDER attribute for the
FRAME element, but not for the FRAMESET element.) Also, removing the border
around a frame makes it difficult to resize it, as this border is also used
in most GUIs to change the size of the frame.
Which should I use, &entityname; or &#number; ?
In HTML, characters can be represented in three ways:
1. a properly coded character, in the encoding specified by the "charset"
attribute of the "Content-type:" header;
2. a character entity (&entityname;), from the appropriate HTML
specification (HTML 2.0/3.2, HTML 4, etc.);
3. a numeric character reference (&#number;) that specifies the Unicode
reference of the desired character. We recommend using decimal references;
hexadecimal references are less widely supported.
In theory these representations are equally valid. In practice, authoring
convenience and limited support by browsers complicate the issue.
HTTP being a guaranteed "8-bit clean" protocol, you can safely send out
8-bit or multibyte coded characters, in the various codings that are
supported by browsers.
A. HTML 2.0/3.2 (Latin-1)
By now there seems no convincing reason to choose &entityname; versus
&#number;, so use whichever is convenient.
If you can confidently handle 8-bit-coded characters this is fine too,
probably preferred for writing heavily-accented languages. Take care if
authoring on non-ISO-8859-based platforms such as Mac, Psion, IBM mainframes
etc., that your upload technique delivers a correctly coded document to the
server. Using &-representations avoids such problems.
B. A single repertoire other than Latin-1
In such codings as ISO-8859-7 Greek, koi8-r Russian Cyrillic, and Chinese,
Japanese and Korean (CJK) codings, use of coded characters is the most
widely supported and used technique.
Although not covered by HTML 3.2, browsers have supported this quite widely
for some time now; it is a valid option within the HTML 4
specifications--use a validator such as the WDG HTML Validator or the W3C
HTML Validation Service which supports HTML 4 and understands different
character encodings.
Browser support for coded characters may depend on configuration and font
resources. In some cases, additional programs called "helpers" or "add-ins"
supply virtual fonts to browsers.
"Add-in" programs have in the past been used to support numeric references
to 15-bit or 16-bit code protocols such as Chinese Big5 or Chinese GB2312.
In theory you should be able to include not only coded characters but also
Unicode numeric character references, but browser support is generally poor.
Numeric references to the "charset-specified" encoding may appear to produce
the desired characters on some browsers, but this is wrong behavior and
should not be used. Character entities are also problematical, aside from
the HTML-significant characters <, & etc.
C. Internationalization per HTML 4
Recent versions of the popular browsers have support for some of these
features, but at time of writing it seems unwise to rely on this when
authoring for a general audience.
Is there a way to prevent getting framed?
"Getting framed" refers to having your documents displayed within someone
else's frameset without your permission. This can happen accidentally (the
frameset author forgot to use TARGET="_top" when linking to your document)
or intentionally (the frameset author wanted to display your content with
his/her own navigation or banner frames).
To avoid "framing" other people's documents, you must add TARGET="_top" to
all links that lead to documents outside your intended scope.
Unfortunately, there is no reliable way to specify that a particular
document should be displayed in the full browser window, rather than in the
current frame. One workaround is to use <BASE TARGET="_top"> in the
document, but this only specifies the default target frame for links in the
current document, not for the document itself.
If the reader's browser has JavaScript enabled, the following script will
automatically remove any existing framesets:
<script type="text/javascript">
if (top.frames.length!=0) {
if (window.location.href.replace)
top.location.replace(self.location.href);
else
top.location.href=self.document.href;
}
</script>
An alternative script is
<script type="text/javascript">
function breakOut() {
if (self != top)
window.open("my URL","_top","");
}
</script>
</HEAD>
<BODY onLoad="breakOut()">
Why aren't my frames the exact size I specified?
Older versions of Netscape Navigator seems to convert pixel-based frame
dimensions to whole percentages, and to use those percentage-based
dimensions when laying out the frames. Thus, frames with pixel-based
dimensions will be rendered with a slightly different size than that
specified in the frameset document. The rounding error will vary depending
on the exact size of the browser window.
Furthermore, Navigator seems to store the percentage-based dimensions
internally, rather than the original pixel-based dimensions. Thus, when a
window is resized, the frames are redrawn based on the new window size and
the old percentage-based dimensions.
There is no way to prevent this behavior. To accommodate it, you should
design your site to adapt to variations in the frame dimensions. This is
another situation where it is a good idea to accommodate variations in the
browser's presentation.
How can I specify background images?
With HTML, you can suggest a background image with the BACKGROUND
attribute of the BODY element. Here is an example:
<body background="imagefile.gif" bgcolor="#ffffff" text="#000000"
link="#0000ff" vlink="#800080" alink="#000080">
If you specify a background image, you should also specify text, link, and
background colors since the reader's default colors may not provide adequate
contrast against your background image. The background color may be used by
those not using your background image. Authors should not rely on the
specified background image since browsers allow their users to disable image
loading or to override document-specified backgrounds.
How can I copy something from a webpage to my webpage?
1: Plaintext or any text information viewable from your browser can be
easily copied like any other text from any other file.
2; HTML and web scripts - you will need to view the web page's source code.
In the page's source code, copying the <script> and </script> tags as well
as all the information in-between these tags will usually enable the script
to work on your web page.
3: Images, sounds, or movies - Almost all images, sounds, and movies can be
copied to your computer and then viewed on your webpage. Images can be
easily copied from a webpage by right-clicking an image and selecting "Save
Picture as" or "Save Image as". Unless the sound or movies file has a direct
link to download and save the file to a specified location on your hard disk
drive or to view your Internet browser's cache and locate the sound or movie
file saved in the cache.
4. Embedded objects - Looking at the source code of the object to determine
the name of the file and how it is loaded, and copy both the code and the
file.
Is it possible to make the HTML source not viewable?
In short, there is no real method or script for making standard HTML
source code not viewable. You may consider doing any of the below if they
are concerned about your source code.
1. Create the web page in Macromedia Flash or a similar program. The visitor
would need to download the Macromedia Flash plug-in and would be unable to
view the source code for the flash applet.
2. There are various scripts that will disable the right click feature,
preventing the user from saving images or viewing the source. However, this
will not protect the source code of your page. For example, Internet
Explorer users may still click "View" and "Source" to view the source code
of the page, or a user could disable scripts and images can be saved by
simply saving the web page to the hard drive.
3. There are several programs that will help scramble your code, making it
difficult (not impossible) to read. Again, this is not going to prevent
someone from viewing your code.
Why doesn't my title show up when I click "check it out"?
You're probably looking at the wrong part of the screen. The Title
usually shows up in the Title Bar on the Window, to the left of the
minimize/maximize buttons on graphical browsers.
How do I make a thumbnail for my image(s)?
Thumbnails are very useful, but they take a little bit of time to make.
All you need is a graphics editing program that has functions to resize an
image (sometimes it's under a function called image attributes). Be
advised--when you have made a thumbnail, you will need to save it as
something different than the original. Also, you will generally want to link
to the larger graphic when you are done.
Here are the steps:
1. Load a copy of the image into your graphics editing program.
2. Determine the ratio the thumbnail to be. (Do you want it to be half the
size? One third of the size? One quarter of the size? One tenth of the
size?)
3. Find the resize (or change attributes) function of your program. Most
programs will recogize a percentage, for example you can type in 25% for
height and width if you want the thumbnail to be a quarter of the size. (It
it doesn't do percentages, you can calculate it by multiplying the pixels by
the percentage. If you have a graphic that is 400 by 100, and you want it
25% of the size, multiple each measurement by .25. In this case, you'll get
100 and 25.)
4. Once you are satisfied with the thumbnail, think of a name for the image.
Choose Save As and enter that name. (Tip: I like to just add t after the
image name. For taco.jpg I'd use tacot.jpg)
5. Upload the image to your site, and edit your HTML to load the new image
name with the new, smaller size. If you wish, you can link to the larger
image around the image.
Example: You have taco.jpg which is 400 pixels wide and 100 pixels high. You
made a thumbnail of it called tacot.jpg, which is now 100 pixels wide and 25
pixels high. After you have both images uploaded, here's the code:
<a href="taco.jpg"><img src="tacot.jpg" width=100 height=25 border=0
alt="click for larger taco"></a>
You'll find border=0 to be helpful in eliminating a link-colored box around
your thumbnail.
What is the difference between the HTML form methods GET and
POST?
The method parameter specifies which method the client is using to send
information to the WEB server. The method determines which parameter you
will find the CGI request data in:
* POST - post_args
* GET - httpargs
How do I rename all the files from .htm to .html after copying
them from a PC to a UNIX machine?
UNIX's mv (`move') command won't handle wildcard filenames. However,
there's a program called htmaddl (for `HTM-add-"L"'), so you can login and
type htmaddl. This will rename all .htm files to .html
If you haven't got this program on your UNIX machine, you can type it into a
file called htmaddl:
#! /bin/sh
for f in *.htm; do
base=`basename $f .htm`
mv $f $base.html
done
After saving it and exiting your editor, make it executable by typing the
command
chmod ugo+x htmaddl
Best of all, move it into your ~/bin directory, or ask your WebMeister to
put it in /usr/local/bin so everyone can use it.
How do I put sounds for older versions of Internet Explorer?
For older versions of Internet Explorer, this technique was used <BG
SOUND="sound.ext">.
Can I use any HTML in the box?
Yes. Any HTML tag that your browser supports will work in the box. So you can
carry tags from chapters to chapters and mix and match...
How to transferring user to new web page automatically?
You will need to use the below meta tag.
<META HTTP-EQUIV="Refresh" CONTENT="2"; URL="http://www.yourname.com">
Placing the above tag in your <HEAD></HEAD> will load yousite.com in 2 seconds.
Changing the 2 value on CONTENT="2" to another value will increase or decrease
the delay until loading the new page.
I'm trying to `include' a HTML document in another document...Is
there a way to do this?
Yes, there are several ways to do this. But remember, HTML is not a
programming language - it doesn't have `directives': it's a markup language, so
trying to compare it to C or Pascal is not going to be very meaningful.
SGML already provides the standard way to do this, using an entry in the DocType
Declaration for a file:
<!doctype html public "-//IETF//DTD HTML 3.0//EN" [
<!entity foo system "bar.html">
]>
...
and then later when you want to include the file
...
&foo;
This is the General Entity mechanism used universally in normal SGML work and
does exactly what is wanted, with the added benefit that you can have multiple
occurrences of &foo; if you need to include some text at more than one place.
Unfortunately none of the browsers except Panorama support it, basically because
very few of the programmers who write browsers bothered to read up on what can
be done.
* The second way is to use the facilities of your server. This has to be enabled
by someone with access to the server configuration files (ask your WebMeister).
For example, the NCSA server lets you embed a command inside an SGML comment:
<!--#exec cmd="cat myfile.html"-->
Provided this occurs in a file with a special file type (eg .shtml, and this is
what has to be specified in the server configuration), the server will parse the
file and send out the result of the command embedded in the document.
* There is in fact a vastly easier way to do this. SGML provides a PI mechanism
(Processing Instruction) in the form:
<?cat myfile>
SGML/HTML couldn't care what you put inside (except it must not, for obvious
reasons, contain the `>' character!). This would be a great way to specify a
page break, for example: suppose you were processing an SGML file using
PostScript, you could say <?showpage>...but again, none of the browsers except
Panorama support this, again because they guys who write them have never
bothered to actually read up on how SGML works.
How do I keep people from stealing my source code and/or images?
Because copies of your HTML files and images are stored in cache, it is
impossible to prevent someone from being able to save them onto their hard
drive. If you are concerned about your images, you may wish to embed a watermark
with your information into the image. Consult your image editing program's help
file for more details.
The colors on my page look different when viewed on a Mac and a PC.
The Mac and the PC use slightly different color palettes. There is a 216
"browser safe" color palette that both platforms support; the Microsoft color
picker page has some good information and links to other resources about this.
In addition, the two platforms use different gamma (brightness) values, so a
graphic that looks fine on the Mac may look too dark on the PC. The only way to
address this problem is to tweak the brightness of your image so that it looks
acceptable on both platforms.
How do you create tabs or indents in Web pages?
There was a tag proposed for HTML 3.0, but it was never adopted by any major
browser and the draft specification has now expired. You can simulate a tab or
indent in various ways, including using a transparent GIF, but none are quite as
satisfactory or widely supported as an official tag would be.
My page looks good on one browser, but not on another.
There are slight differences between browsers, such as Netscape Navigator and
Microsoft Internet Explorer, in areas such as page margins. The only real answer
is to use standard HTML tags whenever possible, and view your pages in multiple
browsers to see how they look.
How do I make sure my framed documents are displayed inside their
frameset?
When the sub-documents of a frameset state are accessed directly, they appear
without the context of the surrounding frameset.
If the reader's browser has JavaScript support enabled, the following script
will restore the frameset:
<SCRIPT TYPE="text/javascript">
if (parent.location.href == self.location.href) {
if (window.location.href.replace)
window.location.replace('frameset.html');
else
// causes problems with back button, but works
window.location.href = 'frameset.html';
}
</SCRIPT>
A more universal approach is a "restore frames" link:
<A HREF="frameset.html" TARGET="_top">Restore Frames
Note that in either case, you must have a separate frameset document for every
content document. If you link to the default frameset document, then your reader
will get the default content document, rather than the content document he/she
was trying to access. These frameset documents should be generated
automatically, to avoid the tedium and inaccuracy of creating them by hand.
Note that you can work around the problem with bookmarking frameset states by
linking to these separate frameset documents using TARGET="_top", rather than
linking to the individual content documents.
How do I update two frames at once?
There are two basic techniques for updating multiple frames with a single
link: The HTML-based technique links to a new frameset document that specifies
the new combination of frames. The JavaScript-based solution uses the onClick
attribute of the link to update the additional frame (or frames).
The HTML-based technique can link to a new frameset document with the
TARGET="_top" attribute (replacing the entire frameset). However, there is an
alternative if the frames to be updated are part of a nested frameset. In the
initial frameset document, use a secondary frameset document to define the
nested frameset. For example:
<frameset cols="*,3*">
<frame src="contents.html" name="Contents">
<frame src="frameset2.html" name="Display">
<noframes>
<!-- Alternative non-framed version -->
</body></noframes>
</frameset>
A link can now use the TARGET="Display" attribute to replace simultaneously all
the frames defined by the frameset2.html document.
The JavaScript-based solution uses the onClick attribute of the link to perform
the secondary update. For example:
<a href="URL1" target="Frame1" onClick="top.Frame2.location='URL2';">Update
frames
The link will update Frame1 with URL1 normally. If the reader's browser supports
JavaScript (and has it enabled), then Frame2 will also be updated (with URL2).
Can I have two or more Submit buttons in the same form?
Yes. This is part of HTML 2.0 Forms support (some early browsers did not
support it, but browser coverage is now excellent).
The submit buttons must have a NAME attribute. The optional VALUE attribute can
be used to specify different text for the different submit buttons.
To determine which submit button was used, you need to use different values for
the NAME and/or VALUE attributes. Browsers will send to the server the
name=value pair of the submit button that was used. Here is an example:
<input type="submit" name="join" value="I want to join now">
<input type="submit" name="info" value="Please send full details">
Note that if you are using image submit buttons, you need to provide different
NAME attributes for them too. Also, browser behavior can be inconsistent when
the form is submitted without a submit button (e.g., by hitting ENTER).
If you're unsure what results you're going to get when you submit your form,
TipJar has a standard script which you can use. Code this, for example (assuming
method "post"):
<form method="post" action="http://www.yoursite.com/cgi-bin/test">
and then go through the motions of submitting your form. The TipJar server
decodes the form input, and displays the result to you.
How do I make a link or form in one frame update another frame?
In the frameset document (the HTML document containing the <frameset> <frame>
tags), make sure to name the individual frames using the NAME attribute. The
following example creates a top frame named "navigation" and a bottom frame
named "content":
<frameset rows="*,3*">
<frame name="navigation" src="navigation.html">
<frame name="content" src="content.html">
<noframes><body>
<!-- Alternative non-framed version -->
</body></noframes>
</frameset>
Then, in the document with the link, use the TARGET attribute to specify which
frame should be used to display the link. (The value of the TARGET attribute
should match the value of the target frame's NAME attribute.) For example:
<a target="content" href=...>
To target a form submission, use the TARGET attribute of the FORM element, like
this:
<form target="content" action=...>
Note that when forms are processed entirely by JavaScript, the target frame must
be specified in the JavaScript. The value of the TARGET attribute is irrelevant.
Normally, the default target frame is the current frame ("_self"). To change the
default target for every link/form on the page, use the TARGET attribute of the
BASE element, like this:
<base target="content">
When I try to upload my site, all my images are X's. How do I get
them to load correctly?
They are a few reasons that this could happen. The most common are:
1. You're attempting to use a .bmp or .tif or other non-supported file format.
You can only use .gif and .jpg on the web. You must convert files that are not
.gif or .jpg into a .gif or .jpg with your image/graphics program.
2. You've forgotten to upload the graphic files. Double-Check.
3. You've incorrectly linked to the images. When you are starting out, try just
using the file name in the <img> tag. If you have cat.jpg, use
img src="cat.jpg">.
4. Image file names are case-sensitive. If your file is called CaT.JpG, you
cannot type cat.jpg, you must type CaT.JpG exactly in the src.
5. If all of the above fail, re-upload the image in BINARY mode. You may have
accidentally uploaded the image in ASCII mode.
Is there a site that shows which tags work on which browsers?
There have been several attempts to do this, but I'm not aware of any really
good source of comparisons between the browsers. The trouble is that there are
many different versions of each browser, and many different tags. All current
browsers should support the tags in the official HTML 3.2 specification, but the
major ones also support nonstandard tags and sometimes have slightly different
implementations. One place that has fairly good compatibility info is
Browsercaps.
Why does the browser show my plain HTML source?
If Microsoft Internet Explorer displays your document normally, but other
browsers display your plain HTML source, then most likely your web server is
sending the document with the MIME type "text/plain". Your web server needs to
be configured to send that filename with the MIME type "text/html". Often, using
the filename extension ".html" or ".htm" is all that is necessary. If you are
seeing this behavior while viewing your HTML documents on your local Windows
filesystem, then your text editor may have added a ".txt" filename extension
automatically. You should rename filename.html.txt to filename.html so that
Windows will treat the file as an HTML document.
How can I display an image on my page?
Use an IMG element. The SRC attribute specifies the location of the image.
The ALT attribute provides alternate text for those not loading images. For
example:
<img src="logo.gif" alt="ACME Products">
Why do my links open new windows rather than update an existing
frame?
If there is no existing frame with the name you used for the TARGET
attribute, then a new browser window will be opened, and this window will be
assigned the name you used. Furthermore, TARGET="_blank" will open a new,
unnamed browser window.
In HTML 4, the TARGET attribute value is case-insensitive, so that abc and ABC
both refer to the same frame/window, and _top and _TOP both have the same
meaning. However, most browsers treat the TARGET attribute value as
case-sensitive and do not recognize ABC as being the same as abc, or _TOP as
having the special meaning of _top.
Also, some browsers include a security feature that prevents documents from
being hijacked by third-party framesets. In these browsers, if a document's link
targets a frame defined by a frameset document that is located on a different
server than the document itself, then the link opens in a new window instead.
How do I get out of a frameset?
If you are the author, this is easy. You only have to add the TARGET
attribute to the link that takes readers to the intended 'outside' document.
Give it the value of _top.
In many current browsers, it is not possible to display a frame in the full
browser window, at least not very easily. The reader would need to copy the URL
of the desired frame and then request that URL manually.
I would recommend that authors who want to offer readers this option add a link
to the document itself in the document, with the TARGET attribute set to _top so
the document displays in the full window if the link is followed.
How do I make a frame with a vertical scrollbar but without a
horizontal scrollbar?
TThe only way to have a frame with a vertical scrollbar but without a
horizontal scrollbar is to define the frame with SCROLLING="auto" (the default),
and to have content that does not require horizontal scrolling. There is no way
to specify that a frame should have one scrollbar but not the other. Using
SCROLLING="yes" will force scrollbars in both directions (even when they aren't
needed), and using SCROLLING="no" will inhibit all scrollbars (even when
scrolling is necessary to access the frame's content). There are no other values
for the SCROLLING attribute.
Are there any problems with using frames?
The fundamental problem with the design of frames is that framesets
create states in the browser that are not addressable. Once any of the
frames within a frameset changes from its default content, there is no
longer a way to address the current state of the frameset. It is difficult
to bookmark - and impossible to link or index - such a frameset state. It is
impossible to reference such a frameset state in other media. When the
sub-documents of such a frameset state are accessed directly, they appear
without the context of the surrounding frameset. Basic browser functions
(e.g., printing, moving forwards/backwards in the browser's history) behave
differently with framesets. Also, browsers cannot identify which frame
should have focus, which affects scrolling, searching, and the use of
keyboard shortcuts in general.
Furthermore, frames focus on layout rather than on information structure,
and many authors of framed sites neglect to provide useful alternative
content in the NOFRAMES element. Both of these factors cause accessibility
problems for browsers that differ significantly from the author's
expectations and for search engines.
Do search engines dislike frames?
Search engines can link directly to framed content documents, but they
cannot link to the combinations of frames for which those content documents
were designed. This is the result of a fundamental flaw in the design of
frames.
Search engines try to provide their users with links to useful documents.
Many framed content documents are difficult to use when accessed directly
(outside their intended frameset), so there is little benefit if search
engines offer links to them. Therefore, many search engines ignore frames
completely and go about indexing more useful (non-framed) documents.
Search engines will index your <NOFRAMES> content, and any content that is
accessible via your
|