CSS: The difference between display: none and visibility: hidden.

The display: none and visibility: hidden CSS properties appear to be the same thing, but they aren’t.

These two style properties do two different things.

visibility: hidden” hides the element, but it still takes up space in the layout.

“display: none” removes the element completely from the document. It does not take up any space, even though the HTML for it is still in the source code.

You can see the effect of these style properties on this page. I created three identical swatches of code, and then set the display and visibility properties on two so you can see how they look.

Example Code:

<div class="div">
<img src="maliwithcar_tn.jpg" alt="mali" class="basic" />
<p>This is a picture of my cat Mali. She is sitting next to a model of my Audi TT. She enjoys chasing it, especially when it runs into her. I especially liked this picture because it looks like a giant cat is attacking a car. Okay, you have to use your imagination…</p>
</div>

div { border: 1px solid black; }
img { float: left; padding: 5px; }

Set visibility: hidden on the image

This is a picture of my cat Mali. She is sitting next to a model of my Audi TT. She enjoys chasing it, especially when it runs into her. I especially liked this picture because it looks like a giant cat is attacking a car. Okay, you have to use your imagination…

Here is the code:

<div style="border:1px solid black;">
<img style="float: left; padding: 5px; visibility: hidden;" class="basic" alt="mali" src="http://0.tqn.com/d/webdesign/1/0/N/6/maliwithcar_tn.jpg">
<p>This is a picture of my cat Mali. She is sitting next to a model of my Audi TT. She enjoys chasing it, especially when it runs into her. I especially liked this picture because it looks like a giant cat is attacking a car. Okay, you have to use your imagination…</p>
</div>

img { float: left; padding: 5px; visibility: hidden; }

Set display: none on the image

This is a picture of my cat Mali. She is sitting next to a model of my Audi TT. She enjoys chasing it, especially when it runs into her. I especially liked this picture because it looks like a giant cat is attacking a car. Okay, you have to use your imagination…

Here is the code:

<div style="border:1px solid black;">
<img style="float: left; padding: 5px; display:none;" class="basic" alt="mali" src="http://0.tqn.com/d/webdesign/1/0/N/6/maliwithcar_tn.jpg">
<p>This is a picture of my cat Mali. She is sitting next to a model of my Audi TT. She enjoys chasing it, especially when it runs into her. I especially liked this picture because it looks like a giant cat is attacking a car. Okay, you have to use your imagination…</p>
</div>

img { float: left; padding: 5px; display: none; }

CSS3 Multiple Backgrounds

Here is a very simple example showing the use of multiple background images in one div.

Code below:

#multipleBG {
border: 5px solid #cccccc;
background:url(img1) top left no-repeat, url(img2) bottom left no-repeat, url(img3) bottom right no-repeat;
padding: 15px 25px;
height: inherit;
width: 590px;
}

How to make a DIV absolute center in Browser display area.

Here is the Code . Copy this and paste it in the HTML editor and see the preview in browser

<div style="width:400px;height:200px;position:absolute;top:50%;left:50%;margin-left:-200px;margin-top:-100px;background:#e5e5e5;border:5px solid #999999;z-index:999;-moz-box-shadow:0 5px 5px #000000;-webkit-box-shadow:0 5px 5px #000000;-moz-border-radius:20px;-webkit-border-radius:20px;"> <h2 style="margin:20px;">This will be perfectly Center aligned. Now resize th browser window and see that the DIV will be dynamically centered.
</div>

Rounded Corner, Gradient buttons with shadows with only <a> tag – CSS3

Try this pasting in your HTML editor and see the result. If it is Dreamweaver paste it in HTML source editor.

<style>
  a.TryRedButton 
  		{
        -moz-border-radius: 8px;
        -webkit-border-radius: 8px; 
        color:#ffffff;
        -moz-box-shadow: 0 2px 2px #000000;
        -webkit-box-shadow: 0 2px 2px #000000; 
        border:1px solid #333333;  
        background-image: -moz-linear-gradient(top left -90deg, #585858, #3f3f3f); 
        padding: 5px 10px; 
        text-decoration:none; 
        text-shadow: 1px 1px 1px #000000;}
  a.TryRedButton:hover 
  		{
        background-image: -moz-linear-gradient(top left -90deg, #3f3f3f, #585858);}
  </style>
		
<a class="TryRedButton" href="#">Black Gradient Button</a>

Make a DIV Absolute inside another DIV

How to make a DIV absolute inside another DIV

Here is the code

<div style=”display:block;width:400px;height:200px;position:relative;background:#e5e5e5;”>
<div style=”position:absolute;display:block;width:20px;height:20px;top:20px;right:20px;border:1px solid #333333;”></div>
</div>

This is how it looks.

What’s New in CSS3?

CSS 3

Whas new in CSS3?

This is the third generation of the recommendation from the W3C in regards to CSS. Unlike CSS 2.1, which is still unfinished, CSS3 has been broken up into different unique modules. What this means is that CSS for layout will go into one specific module, and all text properties will go into another module and so on. You are probably wondering what’s the benefit? The benefit is that from browser and implementation perspective, browser developers can now implement CSS3 module by module, instead of implementing entire CSS specification. This helps speed up the entire implementation process.

From a development point of view, CSS3 will allow to:

  • Programmatically style HTML elements
  • Ability to create reflections
  • Ability to define level of opacity
  • Method of applying round corners to block elements and images
  • Method of using images as borders
  • Method of displaying shadow or blur effect
  • Method of using multiple background images on a single block element
  • Method of using any web font as long as license allows it
  • Method of splitting content into columns
  • Method of transforming an element: ex. rotate, resize, skew
  • Method of animating certain properties of an element: ex. fade in/fade out
  • Ability to support non-Latin text
  • And many other even more exciting features which are not only great from design perceptive, but most importantly from semantically correct markup stand point.

Browsers with limited CSS3 support:

  • Firefox
  • Chrome
  • Safari
  • Opera

Internet Explorer 8, 7, and 6 do not support CSS3.

Is CSS3 helpful?

Follow

Get every new post delivered to your Inbox.