HTML Questions and Answers Part-21

1. Which attribute specifies a unique alphanumeric identifier to be associated with an element?
a) class
b) id
c) article
d) html

Answer: b
Explanation: HTML is Hyper Text Markup Language which is used to create web pages and applications. The id attribute is most used to point to a style in a style sheet, and by JavaScript (via the HTML DOM) to manipulate the element with the specific id. Class is a name given to HTML elements which can be used by CSS and JavaScript for styling the web pages. A self-contained content is called attribute.

2. The _____________ attribute specifies an inline style associated with an element, which determines the rendering of the affected element.
a) dir
b) style
c) class
d) article

Answer: b
Explanation: Style attribute specifies an inline style for an element. The style attribute will override any style set globally, e.g. styles specified in the style tag or in an external style sheet. A self-contained content is called attribute. Class is a name given to HTML elements which can be used by CSS and JavaScript for styling the web pages. List of directory files is given by dir tag which is not supported in HTML5.

3. Which attribute is used to provide an advisory text about an element or its contents?
a) tooltip
b) dir
c) title
d) head

Answer: c
Explanation: The extra information about an element is specified by title tag. The information is most often shown as a tooltip text when the mouse moves over the element. List of directory files is given by dir tag which is not supported in HTML5. Tooltip or else infotip is a graphical user interface of an element. Container of metadata is called head.

4. The __________ attribute sets the text direction as related to the lang attribute.
a) lang
b) sub
c) dir
d) ds

Answer: c
Explanation: The dir attribute specifies the text direction of the element’s content. List of directory files is given by dir tag which is not supported in HTML5. The language of an element’s content is given by lang attribute. The subscript text is defined by sub attribute.

5. Which of the following is the attribute that specifies the column name from the data source object that supplies the bound data?
a) dataFormatAs
b) datafld
c) disabled
d) datasrc

Answer: b
Explanation: DataFormatAs specifies how data is rendered. The identifier for data source is set by dataSrc. Datafld attribute specifies the column name from the data source object that supplies the bound data. This attribute is specific to Microsoft’s data binding. A Disabled is a boolean attribute which specifies that <input> element should be disabled.

6. Which of the following is the attribute that indicates the name of the data source object that supplies the data that is bound to this element?
a) dataFormatAs
b) datafld
c) disabled
d) datasrc

Answer: d
Explanation: The identifier for data source is set by dataSrc. When the dataSrc property is applied to a tabular data consumer, the entire data set is repeated by the consuming elements. DataFormatAs specifies how data is rendered. A Disabled is a boolean attribute which specifies that <input> element should be disabled.

7. Which of the following is the attribute that specifies additional horizontal space, in pixels, to be reserved on either side of an embedded item like an iframe, applet, image, and so on?
a) height
b) hspace
c) hidefocus
d) datasrc

Answer: b
Explanation: Height of element is pixels is specified by height attribute. The hspace attribute specifies the whitespace on left and right side of an object. The hidefocus specifies whether a focused rectangle is drawn around an object. The identifier for data source is set by dataSrc.

8. The accesskey attribute specifies a keyboard navigation accelerator for the element.
a) True
b) False

Answer: a
Explanation: The accesskey attribute specifies a shortcut key to activate/focus an element. It specifies a keyboard navigation accelerator for the element. We can use accesskey attribute in forms or links.

9. Which of the following is the attribute that is used to set a global identifier for a microdata item?
a) key
b) id
c) itemclass
d) itemid

Answer: d
Explanation: The unique id for an element in html is specified by id attribute. Itemmid allows a vocabulary to define a global identifier for a microdata item, for example an ISBN number on a book. Use itemid on the same element as the item’s itemscope and itemtype attributes.

10. Which of the following is the attribute that is used to add a name/value pair to a microdata item?
a) itemscope
b) itemref
c) itemprop
d) itemid

Answer: c
Explanation: A boolean global attribute which specifies scope of associated metadata is itemscope. Itemmid is unique global identifier of item. To add a property to an item, the itemprop attribute is used on one of the item’s descendants. Markup without the microdata-related attributes does not have any effect on the microdata model. Itemref provides list of elements id’s with extra/additional properties in the document.