DEV Community

Bidut Sharkar Shemanto
Bidut Sharkar Shemanto

Posted on

HTML, CSS Interview Question&Answer

1) What Do You Understand By The Universal Selector?

Answer:
The universal selector (*) in CSS applies styles to all elements on a web page. It is used to set a common style for all elements without needing to specify each one individually.

2) Differentiate Between The Use Of ID Selector And Class Selector.

Answer:

  • ID Selector (#): Used to style a single, unique element. Each ID must be unique within a document.
  • Class Selector (.): Used to style multiple elements that share the same class. Multiple elements can have the same class.

3) How Can You Use CSS To Control Image Repetition?

Answer:
CSS property background-repeat controls image repetition. For example:

  • background-repeat: repeat; repeats the background image both horizontally and vertically.
  • background-repeat: no-repeat; prevents the background image from repeating.
  • background-repeat: repeat-x; repeats the image horizontally.
  • background-repeat: repeat-y; repeats the image vertically.

4) Are The HTML Tags And Elements The Same Thing?

Answer:
No, HTML tags and elements are not the same.

  • Tags: The code surrounded by angle brackets, such as <div>.
  • Elements: The combination of the opening tag, content, and closing tag, such as <div>Content</div>.

5) Difference Between Inline, Block, And Inline-Block Elements. Is It Possible To Change An Inline Element Into A Block-Level Element?

Answer:

  • Inline Elements: Do not start on a new line and only take up as much width as necessary (e.g., <span>, <a>).
  • Block Elements: Start on a new line and take up the full width available (e.g., <div>, <p>).
  • Inline-Block Elements: Behave like inline elements but can have width and height set like block elements.

Yes, it is possible to change an inline element into a block-level element using CSS:

.element {
    display: block;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)