Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a blank div element?

Tags:

css

I have a blank div class that is called spacer ... it has a blue background and a width of 100% of the container (the body) ...

What I have found is that the spacer will not DISPLAY unless I toss some character in it. I can color the character blue so it is hidden, but that is so inelegant.

What is the CORRECT way to do this.

like image 967
Xofo Avatar asked Aug 12 '10 06:08

Xofo


People also ask

How do you put a blank space in a div?

Just enter &nbsp ; inside your spacer div, but without the space before the semicolon. Alternatively, you could use break tags (<br>) to fill in the space, or a transparent spacer image set to the height you need.

How do I show nothing in CSS?

Like :empty , :blank will select elements that contain nothing at all, or contain only an HTML comment. But, :blank will also select elements that include whitespace, which :empty will not. At the time of this writing, :blank is part of the CSS Selectors Level 4 draft, and is not supported by any browser.

Can div be empty?

A div (or any container element) is considered empty if it does not contain any other elements, text, or whitespace such as spaces or line breaks.


2 Answers

Give it a height.

Otherwise, with no content, it has zero height and is effectively invisible.

like image 86
Ferdinand Beyer Avatar answered Sep 18 '22 05:09

Ferdinand Beyer


Add &nbsp; inside to have some content inside the div

like image 35
khairil Avatar answered Sep 18 '22 05:09

khairil