CSS DISPLAY

The property display specifies whether an element should be visible or not. Should be visible, also specifies how to be visible.

We made invisible HTML element on our page, and will not take up any space, as if nothing had really not there.

This is useful to hide layers that are turned on or off as needed.

CSS Example Display

p.hidden {display:none;}

<p class="hidden">This is a hidden heading</h1>

DISPLAY BLOCK INLINE CSS

A BLOCK element is an element that occupies the entire width available and has a line break before and after.

Examples of HTML elements such BLOCK

<h1>, <p>, <div> <li>

INLINE element is an element that occupies only the width you need and no force line breaks.

Examples of HTML elements such INLINE

<span>, <a>

Changing a BLOCK element to INLINE element, can be helpful in keeping our site as we want and keep web standards.

For example, we can change the BLOCK element <li> to INLINE element <li>, to get a list of options on the same line:

li{display:inline;}

HTML CODE

<ul> <li>ELEMENT 1</li> <li>ELEMENT 2</li> <li>ELEMENT 3</li> </ul>

CSS DISPLAY NONE

The value "none" for the display property allows us to hide an item.

.hidden { display:none; }

We can also hide an element using javascript code:

<script type="text/javascript"> function removeElement(id) { document.getElementById(id).style.display="none"; } </script>

In javascript we can re-display a hidden element:

<script type="text/javascript"> function showElement(id) { document.getElementById(id).style.display="inline"; } </script>