CSS At An End?

XHTML/CSS No Comments »

Ajaxian.com has posted and article regarding frustrations with CSS and the slow rate of adoption by browser vendors. Some comments question the W3C’s effectiveness and the future of the Open Web.

have all been frustrated with CSS over the years. The implementation has been spotty across the browsers, and it has all but died off. IE 7 stepped up and fixed a lot, even if some weren’t happy with how far they got. CSS 3 has been out there for quite some time, but apart from Opera, other browsers have selectively implemented their pet features. Some have done interesting non-standard work too: -mypetfeature-foo-bar.

It sounds like CSS 3 as The Big Unit is basically dead, and small modules are the way forward. We should see good support for CSS 3 selectors, media queries, and who knows what else. Hopefully that new layout manager!

Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.

CSS - Hack Free 2 Column Tableless Layout

XHTML/CSS 10 Comments »

Tableless layouts have generated some heated debates around whether or not they are worth the effort. Many argue why suffer when tables do a good enough job? Well, I talked about standards and semantics in a previous article so I’ll leave that for you to read later. Putting semantic correctness aside, SEO plays a big part in why I made the switch a few years ago. I want to squeeze every last drop of advantage out of my markup as I can. It is not easy getting a top ranking so why make it harder but refusing to optimize your code?

Alright, enough of that, in reality tableless design really isn’t that hard once you have some practice and identify possible cross-browser issues that may arise like clearing floated divs and width differences.

So let’s lay down some structure. You can find the complete source for this article at the end. I am going to only focus on the pieces that apply to tableless design and assume you know the basics of layout a page.

Figure 1


<div id="content">

	<div id="left">

		<!-- 	use a container to avoid using padding and border on #left
				which causes cross-browser inconsistencies with width -->
		<div class="left-container">LEFT</div>

	</div><!-- end #left -->

	<div id="right">

		<!-- 	use a container to avoid using padding and border on #right
				which causes cross-browser inconsistencies with width -->
		<div class="right-container">RIGHT</div>

	</div><!-- end #right -->

	<div class="clear"/>

</div><!-- end #content -->

This is the section we will have to float 2 divs side by side to create our 2 column layout. Before continuing I will explain some pieces of this code. I have used and extra container inside each column of this layout so that I can apply and padding or borders directly to the text and not to the column itself. The reason for this is Firefox, Opera, and other standards compliant browsers add margin and padding to the overall width of the div which will break our float because the 2 columsn width’s will equal greater than the width of the layout wrapper. Internet Explorer doesn’t add margins, etc to the overall width but subtracts them from it.

You’ll notice the div with class=”clear”, this will call the CSS class that will clear our floats. Again Internet Explorer 6 doesn’t require this because of it’s box model bug but other standards browers do need it. Using a break (br) tag is a common practice instead of a div tag but I discovered that Internet Explorer 7 seems to ignore a clearing break but works fine with a clearing div. I am not sure if it is only in select situations but I feel it is best to just avoid trouble altogether.

Now let’s look at our CSS

Figure 2


#wrapper
{
	width: 790px;
	margin: 0 auto;
}

#left
{
	width: 590px;
	background: #dedede;
	float: left;
	height: 500px;
}

.left-container
{
	margin: 20px;
	margin-bottom: 0;	/* IE6 pushes footer down without this */
}

#right
{
	width: 200px;
	background: #b8b8b8;
	float: left;
	height: 500px;
}

.right-container
{
	margin: 20px;
	margin-bottom: 0;	/* IE6 pushes footer down without this */
}

.clear
{
	clear: left;
}

Notice the class clear, this clears the floats in our div, pretty simple. see how I add the margins to the left and right containers so we avoid any width problems. the width for #left and #right add up to the width of #wrapper (this contains the while layout) and #left and #right are floated left. I have set the background of each section to a different color so they will be easy to spot.

That’s pretty much it. That wasn’t too painful was it? Copy the source code below and make an HTML page and take a look at the finsihed product. A valid, hack free, 2 column, tableless layout. I didn’t even need a conditional comment.

Article Source


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title>Tableless layout</title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
	<style type="text/css">

		body
		{
			margin: 0;
			font-family: Verdana, Arial, sans-serif;
		}

		#wrapper
		{
			width: 790px;
			margin: 0 auto;
		}

		#header
		{
			padding: 25px;
			background: #eeeeee;
		}

		#content
		{

		}

		#left
		{
			width: 590px;
			background: #dedede;
			float: left;
			height: 500px;
		}

		.left-container
		{
			margin: 20px;
			margin-bottom: 0;	/* IE6 pushes footer down without this */
		}

		#right
		{
			width: 200px;
			background: #b8b8b8;
			float: left;
			height: 500px;
		}

		.right-container
		{
			margin: 20px;
			margin-bottom: 0;	/* IE6 pushes footer down without this */
		}

		#footer
		{
			padding: 10px;
			background: #eeeeee;
		}

		.clear
		{
			clear: left;
		}

	</style>
</head>
<body>

	<div id="wrapper">

		<div id="header">
			HEADER
		</div><!-- end #header -->

		<div id="content">

			<div id="left">

				<!-- 	use a container to avoid using padding and border on #left
						which causes cross-browser inconsistencies with width -->
				<div class="left-container">LEFT</div>

			</div><!-- end #left -->

			<div id="right">

				<!-- 	use a container to avoid using padding and border on #right
						which causes cross-browser inconsistencies with width -->
				<div class="right-container">RIGHT</div>

			</div><!-- end #right -->

			<div class="clear"/>

		</div><!-- end #content -->

		<div id="footer">
			FOOTER
		</div><!-- end #footer -->

	</div><!-- end #wrapper -->

</body>
</html>
Sitting the VCP-310 exams can be very helpful in running an online business. Advices on stocks can be given online. But for this a proper site has to be setup. To develop a site one can get help from 70-290, a Microsoft training module. Next a good hosting service is needed; bluehost is probably the most recommended one out there today. Their colocation hosting is a catch. The advertising of the site is also important. Many strategies can be carried out but affiliate marketing will probably have the most impact. To increase the visibility of the domain seo can be carried out.
Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.

Find unused CSS selectors with “Dust-Me Selectors”

XHTML/CSS No Comments »

Ever need to find unused CSS styles? This is for you!

If you’ve ever worked on a large project — especially where several people are all working on the same stylesheets — you’ll know how quickly it can get out-of-hand. Styles are added over time, then forgotten about, and coming back on a stylesheet months (or in this case, years) later can be a scary experience. How much of that is necessary? You don’t always know, but you fear deleting anything, in case something, somewhere is using it.

I needed a tool that could work this out for me — something I could run in the background during development that would build up a profile of which rules are not being used anywhere. And since there wasn’t anything out there to do this job (at least, nothing that I or any of my colleagues could find), I wrote my own — initially as a Greasemonkey script, and finally as a full-blown Firefox extension.

And here it is — enjoy!

Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.

Web Standards and Semantics

Software Design, XHTML/CSS 1 Comment »

The Internet has matured alot since it’s inception. It has under gone many changes and today we are seeing some amzing things done with various Internet technologies. One of the key factor in this vast amount of rich and interactive data is Web Standards.

Web standards have allowed us to transmit and share data in reliable and predictable ways. Semantics is a component of Standards, although not as important as a defined structure for the data, that describes the data it contains. Semantics, in many ways, is about common sense. It makes sense to expect a paragraph tag (<p>) to contain a paragraphic of text. It would also make sense to expect a table to contain a grid or table of data. So why are tables used for layouts?

That in and of it’s self is a very interesting question. While the we have made great advances there are still some areas that are a little slow in catching on, for whatever reason. One area is XHTML. While the XHTML specifiaction has been out for years there are still many developers using HTML 4. I was even talking to a fellow developer the other day and a company he is working with still has the bulk of their web work in HTML 3.2, the horror!

Perhaps it is the fact that Internet Explorer still doesn’t correctly support the XHTML mime type (XML application) that developers have asked, “Why bother?” Or perhaps some just don’t see the benefit in making the switch. Now to be clear I am not saying we have to go back and convert evry website or application we have ever written but at least any new development should be in XHTML.

Why bother? Well, for me anyways, one big reason is Google. The search engine giant is favoring semantic and clean markup in it’s page indexing. So a little extra effort when writing your markup can have big payoffs down the road.

So back to the question of why tables for layouts. Well there are many arguments like tabled layouts take longer to load and are less favorable to search engines, which are probably true. Ultimately every developer must choose for themselves. Believe me if I could cram tableless layouts and semantics down everyones throats I would. I am tired of working on projects that someother person has banaided together with horrible markup and then trying to repair the damage (or at least just figure out what is going on). Whether it is that you’re comfotatble with tables or you think that it is easier just bite the bullet, switch to semantic markup and use tables for what they were made for, tabular data. You’ll be glad you did, maybe not today, maybe not tomorrow, maybe not while your cursing my very existence as you piece together your first layout then look at it in IE6, but someday you will thank me!

Cheers.

When starting a home based business, one should consider taking online certification like 70-296. Not only will you learn the web standards and semantics but also how to develop with a professional approach. The web hosting of the site can be carried out on ipowerweb. Initially email marketing can be done for the site and as it grows the strategies will evolve.


Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.
WP Theme & Icons by N.Design Studio
Entries RSS Login