htmlbook.ru - Для тех, кто делает сайты
Статьи Книги Шаг за шагом Рецепты Форум
Главная страница > Свойства CSS > empty-cells
Свойства CSS
!important
@charset
@import
@font-face
@media
@page
active
after
background
background-attachment
background-color
background-image
background-position
background-repeat
before
border
border-bottom
border-bottom-color
border-bottom-style
border-bottom-width
border-collapse
border-color
border-left
border-left-color
border-left-style
border-left-width
border-right
border-right-color
border-right-style
border-right-width
border-spacing
border-style
border-top
border-top-color
border-top-style
border-top-width
border-width
bottom
caption-side
clear
clip
color
content
cursor
counter-increment
counter-reset
direction
display
empty-cells
first-child
first-letter
first-line
float
focus
font
font-family
font-size
font-style
font-variant
font-weight
height
hover
lang
left
letter-spacing
line-height
link
list-style
list-style-image
list-style-position
list-style-type
margin
margin-bottom
margin-left
margin-right
margin-top
max-height
max-width
min-height
min-width
orphans
outline
outline-color
outline-style
outline-width
overflow
padding
padding-bottom
padding-left
padding-right
padding-top
page-break-after
page-break-before
page-break-inside
position
quotes
right
table-layout
text-align
text-decoration
text-indent
text-shadow
text-transform
top
unicode-bidi
vertical-align
visibility
visited
white-space
widows
width
word-spacing
z-index
CSS по типам
@-правила
Цвет и фон
Границы
Позиционирование
Размеры
Форматирование
Шрифт
Текст
Список
Отступы
Поля
Таблица
Интерфейс
Контент
Печать
Псевдоклассы
Псевдоэлементы
CSS 3
background-size
border-bottom-left-radius
border-bottom-right-radius
border-radius
border-top-left-radius
border-top-right-radius
box-sizing
opacity
overflow-x
overflow-y
text-overflow
word-wrap
writing-mode
:empty
:first-of-type
:last-child
:last-of-type
:not
:nth-child
:nth-last-child
:nth-of-type
:only-of-type
:root
:target

empty-cells

Internet ExplorerInternet Explorer ChromeChrome OperaOpera SafariSafari FirefoxFirefox
6.0 7.0 8.0 2.0 3.0 4.0 9.2 9.6 10 2.0 3.1 4.0 2.0 3.0 3.6
Нет Нет Да Да Да Да Ошибки Да Да Да Да Да Ошибки Да Да

Краткая информация

Значение по умолчанию show
Наследуется Да
Применяется К <TD>, <TH> или к элементам, у которых display: table-cell
Ссылка на спецификацию http://www.w3.org/TR/CSS21/tables.html#propdef-empty-cells

Версии CSS

CSS 1 CSS 2 CSS 2.1 CSS 3
Нет Да Да Да

Описание

Задает отображение границ и фона в ячейке, если она пустая. При одновременном добавлении к таблице свойства border-collapse со значением collapse, свойство empty-cells игнорируется.

Ячейка считается пустой в следующих случаях:

Добавление неразрывного пробела &nbsp; воспринимается как видимое содержание, т.е. ячейка уже будет непустой.

Синтаксис

empty-cells: show | hide

Значения

show
Отображает границу вокруг ячейки и фон в ней.
hide
Граница и фон в пустых ячейках не отображается. Если все ячейки в строке пустые, то строка прячется целиком.

Пример

HTML 4.01CSS 2.1CSS 3IE 6IE 7IE 8Op 9.6Op 10Sa 3.1Sa 4Cr 3Ff 3.0

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>empty-cells</title>
  <style type="text/css">
   TABLE {
    border: 4px double #399; /* Граница вокруг таблицы */
   }
   TD {
    background: #fc0; /* Цвет фона */
    border: 1px solid #333; /* Граница вокруг ячеек */
    empty-cells: hide; /* Прячем пустые ячейки */
    padding: 5px; /* Поля в ячейках */ 
   }
  </style>
 </head>
 <body>
  <table width="100%">
   <tr>
    <td>Леонардо</td>
    <td>5</td>
    <td>8</td>
   </tr>
   <tr>
    <td>Рафаэль</td>
    <td> </td>
    <td>11</td>
   </tr>
   <tr>
    <td>Микеланджело</td>
    <td>24</td>
    <td> </td>
   </tr>
   <tr>
    <td>Донателло</td>
    <td>&nbsp;</td>
    <td>13</td>
   </tr>
  </table>
 </body>
</html>

Результат данного примера в браузере Chrome показан ни рис. 1. Тот же пример в браузере Internet Explorer 7 продемонстрирован на рис. 2.

Рис. 1

Рис. 1. Вид таблицы в браузере Chrome

Рис. 2

Рис. 2. Вид таблицы в браузере Internet Explorer 7

Браузеры

Internet Explorer до версии 7.0 включительно не поддерживает свойство empty-cells и отображает пустые ячейки всегда так, словно для них установлено empty-cellshide.

Firefox версии 2 и ниже не прячет строку таблицы, если для всех ячеек задано empty-cells: hide и ячейки пусты.

Браузер Opera до версии 9.27 включительно не скрывает строку таблицы и для пустых ячеек отображает цвет фона.

Copyright 2002–2010 Влад Мержевич, по всем вопросам пишите по адресу vlad@htmlbook.ru

О сайте | Планы на будущее | Использование сайта | Борьба с ошибками | Технологии | Поддержать проект