HTML
class 속성
withWalker™
2020. 12. 11. 15:55
다른 요소와 구분하기 위해 사용자는 요소에 class속성을 이용하여 이름을 부여할 수 있다. class속성은 하나 이상 지정할 수 있으며, 스타일시트나 자바스크립트에서 선택자로 사용할 수 있다. 영어와 숫자, -(Hyphen, 하이픈), _(Underscore, 언더바)의 조합으로 이름을 지정할 수 있다.
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
.color-green {
background-color: green;
}
</style>
<script type="text/javascript">
window.onload = function() {
var wrap = document.querySelector('.wrap');
wrap.style.width = '100px';
wrap.style.height= '100px';
wrap.style.backgroundColor = 'red';
}
</script>
</head>
<body class="to-main show color-green">
<div class="wrap">
</div>
</body>
</html>
See the Pen KKgNXmV by Yoo (@spiegel) on CodePen.
반응형