CSS - 문제 미리보기

문제 1291

medium
::before와 ::after pseudo-element 사용 시 반드시 필요한 속성은? ```css h1::before { _____: "★"; color: gold; } ```
A. display
B. position
C. content
D. width

정답: C

::before와 ::after의 필수 content 속성: content 속성의 필수성: • ::before와 ::after는 가상 요소를 생성 • content 속성이 없으면 요소가 렌더링되지 않음 • 빈 값이라도 `content: "";` 필수 content 속성의 다양한 값들: 텍스트 추가: ```css h1::before { content: "★ "; } h1::after { content: " ★"; } ``` 이미지 추가: ```css h1::before { content: url("icon.png"); } ``` 빈 요소 (장식용): ```css .divider::after { content: ""; display: block; width: 100%; height: 1px; background: #ccc; } ``` CSS 카운터 활용: ```css h2::before { content: counter(chapter) ". "; counter-increment: chapter; } ```

💡 학습 팁

이 문제를 포함한 CSS 과목의 모든 문제를 순차적으로 풀어보세요. 진행상황이 자동으로 저장되어 언제든지 이어서 학습할 수 있습니다.