Câu hỏi phỏng vấn CSS
Câu hỏi

Explain the three main ways to apply CSS styles to a web page

Câu trả lời

Certainly! CSS, or Cascading Style Sheets, can be applied to a web page in three main ways: Inline CSS, Internal CSS, and External CSS. Each method has its own use cases and advantages.

Inline CSS

Inline CSS involves adding style directly within an HTML element using the style attribute. This method is useful for applying a unique style to a single element without affecting other elements on the page. However, it is not considered a best practice for styling multiple elements because it can lead to code redundancy and makes the HTML document harder to maintain.

Here's an example of inline CSS:

html Copy
<p style="color: red; font-size: 14px;">This is a paragraph with inline CSS.</p>

Inline CSS has the highest priority over other types of CSS, meaning that it will override both internal and external styles that target the same element[1][2][6].

Internal CSS

Internal CSS, also known as embedded CSS, is placed within the <style> tags in the <head> section of an HTML document. This method is suitable for styling a single web page with unique styles that are not needed on other pages. It keeps the styles separate from the HTML structure, which is cleaner than inline styles, but still maintains the styles within the same document.

An example of internal CSS would be:

html Copy
<head>
  <style>
    body {
      background-color: linen;
    }
    h1 {
      color: navy;
    }
  </style>
</head>

Internal CSS is considered more important than external CSS but less important than inline CSS when it comes to the cascade[2][3][6].

External CSS

External ...

entry

entry

Gợi ý câu hỏi phỏng vấn

junior

Explain what is a @extend directive used for in Sass?

middle

How does CSS actually work (under the hood of browser)?

middle

Explain your understanding of the box model and how you would tell the browser in CSS to render your layout in different box models.

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào