HTML Interview Questions

Get Technical Answers for HTML Interview Questions by Expert Developer, Advanced Technical Questions for Freshers and Experience Persons.

1. What Is Html?

HTML, or Hypertext Markup Language, is a Universal language which allows an individual using special code to create web pages to be viewed on the Internet.

2. What Is A Tag?

In HTML, a tag tells the browser what to do. When you write an HTML page, you enter tags for many reasons -- to change the appearance of text, to show a graphic, or to make a link to another page.

Hyperion Training Online

  • Master Your Craft
  • Lifetime LMS & Faculty Access
  • 24/7 online expert support
  • Real-world & Project Based Learning

 

3. What Is The Simplest Html Page?

HTML Code:

This is my page title!

This is my message to the world!

Browser Display:

This is my message to the world!

Subscribe to our youtube channel to get new updates..!

 

4. How Do I Create Frames? What Is A Frameset?

Frames allow an author to divide a browser window into multiple (rectangular) regions. Multiple documents can be displayed in a single window, each within its own frame. Graphical browsers allow these frames to be scrolled independently of each other, and links can update the document displayed in one frame without affecting the others.

You can't just "add frames" to an existing document. Rather, you must create a frameset document that defines a particular combination of frames, and then display your content documents inside those frames. The frameset document should also include alternative non-framed content in a NOFRAMES element. The HTML 4 frames model has significant design flaws that cause usability problems for web users. Frames should be used only with great care.

Hyperion Training Online

Weekday / Weekend Batches

 

5. How Can I Include Comments In Html?

Technically, since HTML is an SGML application, HTML uses SGML comment syntax. However, the full syntax is complex, and browsers don't support it in its entirety anyway. Therefore, use the following simplified rule to create HTML comments that both have valid syntax and work in browsers:

An HTML comment begins with "", and does not contain "--" or ">" anywhere in the comment.

The following are examples of HTML comments:

* <! -- This is a comment. -->

* <! -- This is another comment,

And it continues onto a second line. -->

*

Do not put comments inside tags (i.e., between "<" and ">") in HTML markup.

6. What Is A Hypertext Link?

A hypertext link is a special tag that links one page to another page or resource. If you click the link, the browser jumps to the link's destination.

7. What Is Everyone Using To Write Html?

Everyone has a different preference for which tool works best for them. Keep in mind that typically the less HTML the tool requires you to know, the worse the output of the HTML. In other words, you can always do it better by hand if you take the time to learn a little HTML.

8. What Is A Doctype? Which One Do I Use?

According to HTML standards, each HTML document begins with a DOCTYPE declaration that specifies which version of HTML the document uses. Originally, the DOCTYPE declaration was used only by SGML-based tools like HTML validators, which needed to determine which version of HTML a document used (or claimed to use).

Today, many browsers use the document's DOCTYPE declaration to determine whether to use a stricter, more standards-oriented layout mode, or to use a "quirks" layout mode that attempts to emulate older, buggy browsers.

9. Can I Nest Tables within Tables?

Yes, a table can be embedded inside a cell in another table. Here's a simple example:

this is the first cell of the outer table

this is the second cell of the outer table,

With the inner table embedded in it

this is the first cell of the inner table

this is the second cell of the inner table

The main caveat about nested tables is that older versions of Netscape Navigator have problems with them if you don't explicitly close your TR, TD, and TH elements. To avoid problems, include every , , and tag, even though the HTML specifications don't require them. Also, older versions of Netscape Navigator have problems with tables that are nested extremely deeply (e.g., tables nested ten deep). To avoid problems, avoid nesting tables more than a few deep. You may be able to use the ROWSPAN and COLSPAN attributes to minimize table nesting. Finally, be especially sure to validate your markup whenever you use nested tables.

10. How Do I Align A Table To The Right (or Left)?

You can use

to float a table to the right. (Use ALIGN="left" to float it to the left.) Any content that follows the closing

tag will flow around the table. Use
or
to mark the end of the text that is to flow around the table, as shown in this example:

The table in this example will float to the right.

...

This text will wrap to fill the available space to the left of (and if the text is long enough, below) the table.

This text will appear below the table, even if there is additional room to its left.

11. How Can I Use Tables to Structure Forms?

Small forms are sometimes placed within a TD element within a table. This can be a useful for positioning a form relative to other content, but it doesn't help position the form-related elements relative to each other.

To position form-related elements relative to each other, the entire table must be within the form. You cannot start a form in one TH or TD element and end in another. You cannot place the form within the table without placing it inside a TH or TD element. You can put the table inside the form, and then use the table to position the INPUT, TEXTAREA, SELECT, and other form-related elements, as shown in the following example.

Account :

Password :

12. How Do I Center A Table?

In your HTML, use

...

In your CSS, use

div.center {

Text-align: center;

}

Div.center table {

Margin-left: auto;

Margin-right: auto;

Text-align: left;

}

13. How Do I Use Forms?

The basic syntax for a form is:

...

When the form is submitted, the form data is sent to the URL specified in the ACTION attribute. This URL should refer to a server-side (e.g., CGI) program that will process the form data. The form itself should contain

* At least one submit button (i.e., an element),

* form data elements (e.g., ,

14. How Can I Check For Errors?

HTML validates check HTML documents against a formal definition of HTML syntax and then output a list of errors. Validation is important to give the best chance of correctness on unknown browsers (both existing browsers that you haven't seen and future browsers that haven't been written yet).

HTML checkers (linters) are also useful. These programs check documents for specific problems, including some caused by invalid markup and others caused by common browser bugs. Checkers may pass some invalid documents, and they may fail some valid ones.

All valuators are functionally equivalent; while their reporting styles may vary, they will find the same errors given identical input. Different checkers are programmed to look for different problems, so their reports will vary significantly from each other. Also, some programs that are called validate (e.g. the "CSE HTML Validated") are really linters/checkers. They are still useful, but they should not be confused with real HTML valuators.

When checking a site for errors for the first time, it is often useful to identify common problems that occur repeatedly in your markup. Fix these problems everywhere they occur (with an automated process if possible), and then go back to identify and fix the remaining problems.

Link checkers follow all the links on a site and report which ones are no longer functioning. CSS checkers report problems with CSS style sheets.

15. Do I Have To Memorize A Bunch Of Tags?

No. Most programs that help you write HTML code already know most tags, and create them when you press a button. But you should understand what a tag is, and how it works. That way you can correct errors in your page more easily.

16. How Do I Make A Form So It Can Be Submitted By Hitting Enter?

The short answer is that the form should just have one and no TEXTAREA, though it can have other form elements like checkboxes and radio buttons.

17. How Do I Set The Focus To The First Form Field?

You cannot do this with HTML. However, you can include a script after the form that sets the focus to the appropriate field, like this:

A similar approach usesto set the focus, but some browsers seem to process the ONLOAD event before the entire document (i.e., the part with the form) has been loaded.

18. How Can I Eliminate The Extra Space After A Tag?

HTML has no mechanism to control this. However, with CSS, you can set the margin-bottom of the form to 0. For example:

You can also use a CSS style sheet to affect all the forms on a page:

Form {margin-bottom: 0 ; }

19. How Can I Show Html Examples Without Them Being Interpreted As Part Of My Document?

Within the HTML example, first replace the "&" character with "&" everywhere it occurs. Then replace the "<" character with "<" and the ">" character with ">" in the same way.

Note that it may be appropriate to use the CODE and/or PRE elements when displaying HTML examples.

20. How Do I Eliminate The Blue Border Around Linked Images?

In your HTML, you can specify the BORDER attribute for the image:

...

However, note that removing the border that indicates an image is a link makes it harder for users to distinguish quickly and easily which images on a web page are clickable.

21. How Can I Specify Colors?

If you want others to view your web page with specific colors, the most appropriate way is to suggest the colors with a style sheet. Cascading Style Sheets use the color and background-color properties to specify text and background colors. To avoid conflicts between the reader's default colors and those suggested by the author, these two properties should always be used together.

With HTML, you can suggest colors with the TEXT, LINK, VLINK (visited link), ALINK (active link), and BGCOLOR (background color) attributes of the BODY element.

Note that these attributes are deprecated by HTML 4. Also, if one of these attributes is used, then all of them should be used to ensure that the reader's default colors do not interfere with those suggested by the author. Here is an example:

Authors should not rely on the specified colors since browsers allow their users to override document-specified colors.

22. How Can I Allow File Uploads To My Web Site?

These things are necessary for Web-based uploads:

* An HTTP server that accepts uploads.

* Access to the /cgi-bin/ to put the receiving script. Prewritten CGI file-upload scripts are available.

* A form implemented something like this:

File to upload:

Notes about the file:

to upload the file!

Not all browsers support form-based file upload, so try to give alternatives where possible.

The Perl CGI.pm module supports file upload. The most recent versions of the cgi-lib.pl library also support file upload. Also, if you need to do file upload in conjunction with form-to-email, the Perl package MIME::Lite handles email attachments.

23. How Can I Require That Fields Be Filled In, Or Filled In Correctly?

Have the server-side (e.g., CGI) program that processes the form submission send an error message if the field is not filled in properly. Ideally, this error message should include a copy of the original form with the original (incomplete or incorrect) data filled in as the default values for the form fields. The Perl CGI.pm module provides helpful mechanisms for returning partially completed forms to the user.

In addition, you could use JavaScript in the form's ONSUBMIT attribute to check the form data. If JavaScript support is enabled, then the ONSUBMIT event handler can inform the user of the problem and return false to prevent the form from being submitted.

24. How Do I Change The Title Of A Framed Document?

The title displayed is the title of the frameset document rather than the titles of any of the pages within frames. To change the title displayed, link to a new frameset document using TARGET="_top" (replacing the entire frameset).

25. How Do I Link An Image To Something?

Just use the image as the link content, like this:

...

26. How Do I Specify A Specific Combination Of Frames Instead Of The Default Document?

This is unfortunately not possible. When you navigate through a site using frames, the URL will not change as the documents in the individual frames change. This means that there is no way to indicate the combination of documents that make up the current state of the frameset.

The author can provide multiple frameset documents, one for each combination of frame content. These frameset documents can be generated automatically, perhaps being created on the fly by a CGI program. Rather than linking to individual content documents, the author can link to these separate frameset documents using TARGET="_top". Thus, the URL of the current frameset document will always specify the combination of frames being displayed, which allows links, bookmarks, etc. to function normally.

27. How Do I Create A Link?

Use an anchor element. The HREF attribute specifies the URL of the document that you want to link to. The following example links the text "Web Authoring FAQ" to <URL:http://www.htmlhelp.com/faq/html/>:

Web Authoring FAQ

28. How Do I Create A Link That Opens A New Window?

opens a new, unnamed window.

opens a new window named "example", provided that a window or frame by that name does not already exist.

Note that the TARGET attribute is not part of HTML 4 Strict. In HTML 4 Strict, new windows can be created only with JavaScript. links that open new windows can be annoying to your readers if there is not a good reason for them.

29. How Do I Create A Button Which Acts Like A Link?

This is best done with a small form:

If you want to line up buttons next to each other, you will have to put them in a one-row table, with each button in a separate cell.

30. How Can I Make A Form With Custom Buttons?

Rather than a normal submit button (), you can use the image input type (). The image input type specifies a graphical submit button that functions like a server-side image map.

Unlike normal submit buttons (which return a name=value pair), the image input type returns the x-y coordinates of the location where the user clicked on the image. The browser returns the x-y coordinates as name.x=000 and name.y=000 pairs.

Ronments, the VALUE and ALT attributes should be set to the same value as the NAME attribute. For example:

For the reset button, one could use

31. How Do I Specify Page Breaks In Html?

There is no way in standard HTML to specify where page breaks will occur when printing a page. HTML was designed to be a device-independent structural definition language, and page breaks depend on things like the fonts and paper size that the person viewing the page is using.

Submit an interview question

Categories

Request for more information

John
John
Cloud Technologies & Cyber Security
John is a Post Graduate in Computer Science from Andhra University .She is currently working as an IT developer at hkr trainings.com. And he has great experience includes both IT development and operational roles. Connect with him on LinkedIn and Twitter. Thank you

WhatsApp
To Top