관리 메뉴

KorSA

[ HTML/CSS ] BEM (Block__Element--Modifier) 본문

Knowledge Wiki/HTML&CSS

[ HTML/CSS ] BEM (Block__Element--Modifier)

Praiv. 2021. 12. 7. 10:29
320x100

1. 클래스 작명할 때 뭐할지 모르겠으면 BEM(Block__Element--Modifier) 룰을 따르면 좋음
    클래스="덩어리이름__역할"
    클래스="덩어리이름__역할--세부특징"

<div class="profile">
	<img class="profile__img">
	<h4 class="profile__title"></h4>
	<p class="profile__content"></p>
	<button class="profile__button--red"></button>
	<button class="profile__button--blue"></button>
</div>


    클래스="덩어리이름-역할" 방식도 좋음

<div class="profile">
	<img class="profile-img">
	<h4 class="profile-title"></h4>
	<p class="profile-content"></p>
	<button class="profile-button--red"></button>
	<button class="profile-button--blue"></button>
</div>


    React, Vue 쓰면 클래스 작명이 많이 안 겹침. Component 단위로 어차피 범위가 나뉘니까.

728x90
728x90

'Knowledge Wiki > HTML&CSS' 카테고리의 다른 글

[ HTML/CSS ] 제목 아이콘 커스터마이징 - favicon  (0) 2021.12.08
[ HTML/CSS ] 폰트  (0) 2021.12.08
[ HTML/CSS ] OOCSS (Object Oriented CSS)  (0) 2021.12.07
[ HTML/CSS ] pseudo-class  (0) 2021.12.07
[ HTML/CSS ] 표, <table>  (0) 2021.12.07
Comments