section p { color: blue; }
<html>
<head>
<meta charset="utf-8">
<style>
section p {
color: blue;
}
</style>
</head>
<body>
<section>
<p>
<span>애국가</span>
동해물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세.
</p>
<span>동해물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세.</span><br/>
</section>
</body>
</html>
실행 화면
section > p { color: blue; }
<html>
<head>
<meta charset="utf-8">
<style>
section > p {
color: blue;
}
</style>
</head>
<body>
<section>
<p>
<span>애국가</span>
동해물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세.
</p>
<span>동해물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세.</span><br/>
</section>
</body>
</html>
실행 화면
요소 1 + 요소2
<html>
<head>
<meta charset="utf-8">
<style>
section p + span {
color: blue;
}
</style>
</head>
<body>
<section>
<p>
<span>애국가</span>
동해물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세.
</p>
<span>동해물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세.</span><br/>
<span>동해물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세.</span><br/>
</section>
</body>
</html>
실행 화면
요소 1 ~ 요소 2
<html>
<head>
<meta charset="utf-8">
<style>
section p ~ span {
color: blue;
}
</style>
</head>
<body>
<section>
<p>
<span>애국가</span>
동해물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세.
</p>
<span>동해물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세.</span><br/>
<span>동해물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라 만세.</span><br/>
</section>
</body>
</html>
실행 화면
[CSS] 가상 클래스와 가상 요소 (0) | 2021.05.13 |
---|---|
[CSS 기초] 속성 선택자 (0) | 2021.05.12 |
[HTML5] 시맨틱 태그 (0) | 2021.05.10 |
[CSS 기초] 표 스타일 (2) (0) | 2021.05.07 |
[CSS 기초] 표 스타일 (1) (0) | 2021.05.06 |
댓글 영역