초보 테이블 배경색 관련 질문 좀 드립니다.
본문
아래와 같은 내용에서 <table>전체에 배경색을 "ebebeb"로 넣고 싶은데요 현재 테이블 백경색이<td>부분에만 적용이 되고 나머지는 걍 흰색이네요 ㅎㅎ 그렇다고 width 를 100%로 하닌가 <td>부분이 "center"로 몰리지 않고 흩어지네요 고수님들 조언 좀 부탁드립니다. 감사합니다 "꾸벅"
<table align="center" width="1250" bgcolor="ebebeb" border="0" cellspacing="10" cellpadding="0">
<tr>
<td width="300" height="300" align="center"> <img src="<?=$g4['path']?>/img/main_bottom.jpg" border="0" width="300" height="300"></td>
<td width="300" height="300" align="center"> <img src="<?=$g4['path']?>/img/main_bottom.jpg" border="0" width="300" height="300"></td>
<td width="300" height="300" align="center"> <img src="<?=$g4['path']?>/img/main_bottom.jpg" border="0" width="300" height="300"></td>
<td width="300" height="300" align="center"> <img src="<?=$g4['path']?>/img/main_bottom.jpg" border="0" width="300" height="300"></td>
</tr>
</table>
답변 2
<style type="text/css">
table tr td { background: #ebebeb; }
</style>
이런식으로 해당 테이블과 하위 tr td 모두 배경을 지정할수 있습니다.
만약 특정 테이블만 하고 싶으시면
<style type="text/css">
.tableclass table tr td { background: #ebebeb; }
</style>
이런식으로 하시고
<table class="tableclass" ... 처럼 해당 테이블 내에 클래스를 지정해주시면됩니다.
<table style="background:#ebebeb">
align 태그나 td나 테이블에 width, height 속성을 집어넣는것은 최근에 권장되지 않는 방식입니다
스타일시트를 활용하세요