HTML and CSS interview Questions

36 flashcards · Computer Science · by Moses John Prakash

  1. What is HTML?

    Hypertext Markup Language used to create and structure website templates or web pages

  2. what is <!DOCTYPE HTML> declaration ?

    used to inform the browser about the version of HTML used in the document. It is called as the document type declaration (DTD).

  3. What is the structure of a HTML document ?

    <html> <head></head><body></body></html>

  4. What are the three building blocks of HTML ?

    TAGS, ELEMENTS and ATTRIBUTES

  5. What is a tag ?

    It is apiece of markup language which indicates the browser how to format and display the content.

  6. What are the types of tags ?

    Paired and unpaired tags. (container or stand alone tags) Self closing tags.

  7. what is a paired tag ?

    Tag that consists of an opening tag, closing tag and content in between

  8. What is an unpaired tag ?

    The tag that has only an opening tag and does not have a closing tag.

  9. What is a self closing tag ?

    tags that do not have a partner tag, where the first tag is the only necessary tag that is valid for the formatting. Example <img> tag

  10. What is an attribute in HTML ?

    Attributes are special words used inside the opening tag to control the element's behavior. they are always specified in the opening tag.

  11. What is an element ?

    Element is a collection of start tag, attributes, closing tag and content in between them

  12. What are the two categories of elements ?

    a. Block level element b. Inline element

  13. What is a block level element ?

    A block-level element always start with new line and takes the full width of web page, from left to right.

  14. Name some block level elements ?

    <address>, <article>, <aside>, <blockquote>, <dd>, <div>, <dl>, <dt>, <fieldset>, <figcaption>, <figure>, <footer>, <form>, <h1>-<h6>, <header>, <hr>, <li>, <main>, <nav>,, <ol>, <output>, <p>, <pre>, <section>, <table>, <ul> and <video>.

  15. What is an inline element ?

    Inline elements display in a line. They do not force the text after them to a new line.

  16. What are the most commonly used list types ?

    Orderd list or numbered list Unordered list or Bulleted list Definition list or Description list.

  17. What is an ordered list ?

    Displays elements in numerical or alphabetical order. It starts with the tag <ol>

  18. What is the difference between div tag and span tag ?

    A div element is used for block-level organization and styling of page elements, whereas a span element is used for inline organization and styling.

  19. What is a link in html ?

    It is an HTML object which allows the user to navigate from one web resource to another.

  20. Which attribute in link is used to open the web document in a new tab ?

    target="_blank"

  21. What is an iframe ?

    It is used to display a web page within a web page (to embed another document within the current HTML document).

  22. What is the difference between padding and margin ?

    a margin is the space around an element’s border, while padding is the space between an element’s border and the element’s content. OR the margin property controls the space OUTSIDE an element, and the padding property controls the space INSIDE an element.

  23. what is a form in html ?

    An HTML form facilitates the user to enter data that is to be sent to the server for processing.

  24. What are the commonly used input types in form ?

    text , password, date, email, radio button, checkbox, submit, number etc...

  25. What is CSS ?

    It is a rule based language which is used to describe the look and formatting of a document written in markup language.

  26. What are the ways to add style to a html document ?

    Inline styling : Using the style attribute in a specific html element. Internal or embedded styling : Using <style> tag inside head tag. External Styling : Using a separate style sheets and linking those in the required html document using <link> tag.

  27. What is are selectors in CSS ?

    Selectors are used to find (select) the html elements for which styling should be applied.

  28. What are the types of selectors in CSS ?

    Element selector ID selector Class selector Universal selector group selector

  29. What is an element selector ?

    The element selector selects the HTML element by name. Example : h {color:blue;}

  30. What is a ID selector ?

    The id selector selects the id attribute of an HTML element to select a specific element. An id is always unique within the page so it is chosen to select a single, unique element.

  31. What are the elements of BOX MODEL ?

    Content, Padding , Border and Margin

  32. What is a Box Model in css

    The CSS box model defines the layout and design of CSS elements

  33. How can you target h3 and h2 with the same styling?

    Multiple elements can be targeted by separating with a comma Ex: h2, h3 {color: red;}

  34. How can you use CSS to control image repetition?

    The background-repeat property is used to control the image EX: background-repeat: none;

  35. Explain responsive web design.

    Responsive Design is a web page creation approach that uses flexible images, flexible layouts, and CSS media queries. This design approach aims to build web pages that detect the orientation and screen size of the visitors so that the layout can be changed accordingly.

  36. What are Pseudo classes?

    Pseudo-classes are the type of pseudo-elements that don’t exist in a normal document tree. It allows selecting the regular elements under certain conditions especially when we try to hover over the link; the anchor tags are :link, :visited, :hover, :active, :focus