Hypertext Markup Language (HTML) Interview Questions & Answers
Table of Content
In __________ type conversion no loss of data occurs.
- a) Type of the Format is Document File Format in HTML Markup Language in XHTML
- b) Web Pages are written in HTML and XHTML is a very strict version of HTML and based on XML
- c) Tags and attributes are not necessarily to be in lower or upper case in HTML but in XHTML every tag and attribute should be in lower case.
- d) None of the above
Answer - d) None of the above
HTML is designed based on SGML(Standard Generalized Markup Language) however XHTML is based on XML XHTML is the integration of XML application with HTML Web page which are designed using HTML are considered to be as static whereas dynamic when it is created using XHTML Nowadays all browsers supports XHTML (that does not mean it does not support HTML) In XHTML rules(syntax) are very strict and need to follow the same. Example: Doctype which is very much necessary to mention at the beginning of the file). However it is not so strict in HTML NOTE: Errors in HTML are referred to as bad HTML when browsers cannot handle it properly on small devices like mobile But, XHTML has an added feature of XML which properly makes a webpage. XHTML is a combination of HTML and XML
What is DOM in HTML?
- a) Language dependent application programming
- b) Convention for representing and interacting with objects in html documents
- c) Application programming interface
- d) Hierarchy of objects in ASP.NET
Answer - b) Convention for representing and interacting with objects in html documents
DOM is an API that is language-independent(written on some and called by several other programming languages) and cross-platform(which is designed to work on several other platforms) It supports a service-oriented API provided with remote procedure calls and web services DOM helps in viewing the documents as a tree-like structure the tags in HTML file are treated as objects and defines properties, methods, and events. It helps in modifying the objects without affecting the other objects. Easy to retrieve the values(properties, methods, events) by using objects than through tags. Hence DOM helps in adding, changing, or deleting the HTML elements. Below code snippet illustrate how you can use the document object to access and manipulate HTML elements Finding HTML Elements (Ex: document.getElementById(id)) Changing the innerHTML Element (Ex: element.innerHTML = new HTML content) Add a HTML Element (Ex: document.appendChild(element)) Create a HTML Element(Ex: document.createElement(element)) Remove a HTML Element(Ex: document.removeChild(element)) NOTE: Accessing the document object is nothing but accessing element in an HTML page.
What is the correct syntax of web address?
- a) port://domain.filenmae:path/scheme/prefix
- b) prefix://scheme.port:domain/filename/path
- c) scheme://prefix.domain:port/path/filename
- d) path://prefix.port:domain/filename/scheme
Answer - c) scheme://prefix.domain:port/path/filename
The correct syntax for a web address is scheme://prefix.domain:port/path/filename, where,
-> scheme / protocol is for https(secured) or http,
-> Hostname (prefix+domain+portnumber)
-> prefix is for domain like www,
-> domain denotes domain name,
-> port defines port number,
-> path defines path at server,
-> filename is for name of the document.
Example: http(s)://www.example.com/index.html, which indicates
1. protocol (http/https),
2. below are under Domains or Hostname
a. Sub-Domain name (www)
b. Name of the Domain (example)
c. Top Level Domain(com)
3. file name(path to the file)(index. html).
Which of the following is true regards to local storage in HTML5
- a) The data is NOT passed on by every server request, but used ONLY when asked
- b) Stores large amount of data without affecting the performance of the website
- c) Website can only access data stored by itself in different areas for different websites
- d) All of the above
Answer - d) All of the above
HTML Web storage provides us to store the data within the browser locally Data was stored in cookies before HTML5 which was not that much secured. The storage limit is also better when compared to cookies and the limit is up to 5MB where the stored information is never shared with the server. There is no expiration date for the data and more over the data stored is secured by storing a large amount of data. There are two types of web storage as follows: 1. Local Storage: This uses the "localStorage" object to store the data permanently (until you remove it will be there) 2. Session Storage: This uses the "sessionStorage" object to store the data temporarily (disappears when the browser or current tab is closed) Example: window.localStorage - data is stored without an expiry date window.sessionStorage - data is stored for one session (when the browser is closed, the data will be lost)
Which of the following is true with regards to use of HTML in web-development?
- a) Common language used to display content (text, images, animations, sound and even video) on the web
- b) HTML is made up of tags which describes certain information
- c) It creates a layout of the page
- d) All the above
Answer - d) All the above
HTML is easy to learn, understand and implement. It does not require any additional tools to develop a webpage It is best fitted and understood by all Browsers. It does not have any complications in Editing during update or any changes. It is easy to integrate with other languages It is termed as basic for all the other programming languages.