Sunday, April 22, 2007

CSS and cellspacing=0 cellpadding=0

Very often webmasters use following HTML code for tables to remove free spacing between cells and clear padding within cell.


<table border=0 cellspacing=0 cellpadding=0>
….


Also this code sets zero for border property making it invisible. As alternative way you can use CSS instead pure HTML code to rule table visualization properties. This CSS code remove free spacing and between cells and remove padding within cell for all tables in your html document.


<STYLE type="text/css">


table {
border-collapse : collapse;
}

table td, table th {
padding : 0;
}

</STYLE>


I recommend very nice tool - HTML and CSS Table Border Style Wizard

Saturday, April 21, 2007

To center table using CSS only

To center table using CSS only according CSS specification the following code should be used:


table {
margin-left : auto;
margin-right : auto;
}



This code perfectly works in firefox, opera, netscape and I guess in other browsers :). But when you open such centered table in IE (even IE 7) you may see that table has no alignment. It means that you didn’t declare “DOCTYPE” for your HTML document.

Without a “DOCTYPE” declaration, IE ignore margins definition for block level elements.

So, just add following at beginning of your document:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">

Sunday, September 11, 2005

Modern browsers and CSS2

Web developers who widely used CSS should be mentioned that modern browsers don’t correctly support CSS2 specification. The most CSS2 compatible browser is Firefox. IE doesn’t support new type of classes and some other properties specified in CSS2 specification. But web statistic shows that most part of the internet community used Microsoft IE. When developing you should test your pages in all modern browsers and insure that all is displayed properly.

Saturday, September 10, 2005

Why CSS should be used?

Cascading Style allows obtaining the full control under HTML tagging. CSS allows easily redefining the all default properties of any HTML tag. Using CSS you will open new unique opportunities missing in common HTML.

For example, by means of CSS it's possible to set the tracking between characters and space between text rows. Using CSS properties you can exactly specify the background image position disallowing the repeating of the image within the document.

Using CSS you will create new HTML pages much faster. The styles that were once determined can be used again and again in any part of the HTML document. It's very important to understand that using CSS in external file gives a chance to change properties for all elements in any pages where this style definition is used.

This web-site contains the base steps which will allow you to know about CSS a little more. I sincerely hope that this stuff will help you skilfully use the power of CSS in your web-projects.