DEV Community

Bidut Sharkar Shemanto
Bidut Sharkar Shemanto

Posted on

1

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

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay