<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>techfounder &#187; CSS</title>
	<atom:link href="http://www.techfounder.net/category/webdev/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techfounder.net</link>
	<description>Blog about web development and Internet entrepreneurship</description>
	<lastBuildDate>Mon, 22 Aug 2011 08:36:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Creating embedabble widgets</title>
		<link>http://www.techfounder.net/2010/02/05/creating-embedabble-widgets/</link>
		<comments>http://www.techfounder.net/2010/02/05/creating-embedabble-widgets/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 03:38:39 +0000</pubDate>
		<dc:creator>Eran Galperin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.techfounder.net/?p=461</guid>
		<description><![CDATA[Distribution of embeddable widgets is a common feature in many web services today. The most well known example is probably google's adsense that allows site owners to add google ads to their sites. Embeddable widgets allow a subset of functionality to be used on third-party sites, greatly increasing possible market reach for a web service [...]]]></description>
			<content:encoded><![CDATA[<p>Distribution of embeddable widgets is a common feature in many web services today. The most well known example is probably google's adsense that allows site owners to add google ads to their sites. Embeddable widgets allow a subset of functionality to be used on third-party sites, greatly increasing possible market reach for a web service / application.<br />
<span id="more-461"></span></p>
<h2>What is a [web] widget</h2>
<blockquote><p>... a <strong>web widget</strong> is a portable chunk of code that can be installed  and executed within any separate HTML-based web  page by an end user without requiring additional compilation.<br />
<a href="http://en.wikipedia.org/wiki/Web_widget" target="_blank">Web widget by Wikipedia</a></p></blockquote>
<p>Put simply, we need to provide prospective site owners with a short piece of code (henceforth, the "embed code") that they can place on their sites and have the widget appear without any additional modifications to the site.</p>
<p>How would we go about creating an embeddable widget?</p>
<h2>Cross-site scripting (XSS)</h2>
<p>Cross-site scripting is more often mentioned as a <a href="http://en.wikipedia.org/wiki/Cross-site_scripting" target="_blank">web vulnerability</a> which uses the same technique maliciously to manipulate the target site. In this case, Javascript will be used to create the widget on the host site and not to attack it (you should always beware of including scripts from untrusted sources).</p>
<p>This technique is based on embedding a script &lt;tag&gt; on the host site that will refer to a script residing on your service. The script should then dynamically create the widget on the host site by manipulating the DOM and adding stylesheets and script tags as needed. Dr. Nic gives a nice overview of this technique in <a href="http://drnicwilliams.com/2006/11/21/diy-widgets/" target="_blank">this detailed tutorial</a>.</p>
<p>As the tutorial mentions, your embeddable script should have a unique namespace to avoid colliding with local scripts on the host site. Don't be shy to use a long and verbose name for this purpose. Example:</p>
<pre class="javascript">;<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> techfounder_super_embed = window.<span style="color: #006600;">techfounder_super_embed</span> = <span style="color: #66cc66;">&#123;</span>
		init: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'embedded!'</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>;
	techfounder_super_embed.<span style="color: #006600;">init</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p>Some quick notes:</p>
<ul>
<li>I used a self executing anonymous function. This allows me to declare additional variables and functions other than my main namespace ('techfounder_super_embed' in this case) without polluting the main scope or interferring with existing code on the site.</li>
<li>In order for the main namespace to be available outside of the anonymous function scope, I attach it to the window object.</li>
<li>I preceded the function with a semi-colon to close any potentially open Javascript statement that might have been loaded before it, which would have resulted in an error.</li>
</ul>
<p>As opposed to the advice given in Dr. Nic's article, I usually opt to use an external library such as jQuery, in order to better account for cross-browser differences as well as leverage the power inherent in such libraries. jQuery in particular has the useful <a href="http://api.jquery.com/jQuery.noConflict/" target="_blank">noConflict()</a> method which allows it to work side-by-side with other libraries, and can be loaded from a <a href="http://code.google.com/apis/ajaxlibs/documentation/index.html#jquery" target="_blank">google CDN</a> so it does not add bandwidth load on your server.</p>
<p>As for retrieving data cross-site (from your service server to the host site), there are 3 paths you could take:</p>
<ul>
<li>Embedding extra script tags which include JSON data that is constructed dynamically (as shown in Dr. Nic's tutorial).</li>
<li>Creating an Iframe element that accesses a remote resource (ie, on your server) to retrieve the data, and then passing the data back to the document.</li>
<li>Using a <a href="http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/" target="_blank">JSONP</a> call to simulate a cross-site AJAX request. I personally opt for this technique as I find it the most elegant. jQuery <a href="http://api.jquery.com/jQuery.getJSON/" target="_blank">supports this natively</a> in recent versions, making it almost too easy to implement.</li>
</ul>
<p>An important note to keep in mind that styling the widget elements should be done very explicitly. As the widget is embedded directly into the host document it could be affected by any previously loaded stylesheets. A good start would be to use a CSS reset (such as <a href="http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/" target="_blank">this one</a> by Eric Meyer) and apply it directly to a unique ID that identifies the base widget element.</p>
<h2>Iframe embedding</h2>
<p>An Iframe is the most direct approach to including content from a remote site. It's easy to pass arguments in the Iframe source URL and have a response dynamically built in return. However the Iframe approach suffers from some limitations:</p>
<ul>
<li>You have to specify the Iframe proportions in the embed code and it should match the content exactly, else the content can get truncated. This also means the embed code would need to change if the widget appearance changes (which comes up often for customizable widgets).</li>
<li>There are some security limitations for Iframe scripting, so if you need to manipulate the host site page in any additional way,  you would need to include a script &lt;tag&gt; as well in the initial embed code to <a href="http://www.nczonline.net/blog/2009/09/15/iframes-onload-and-documentdomain/" target="_blank">bypass the security restrictions</a>.</li>
<li>Iframes are invalid markup in XHTML Strict doctype. Depending on the host site doctype declaration, this could present a minor issue (if the host site owner is concerned about with valid markup).</li>
</ul>
<p>A big advantage in using an Iframe over directly embedding the widget in the host page is that you don't have to be concerned with external styles affecting the widget.</p>
<h2>Which should you use</h2>
<p>Cross site scripting is useful when there is a need to dynamically manipulate the host site page. This would include placing the widget in positions different to where the embed code was placed at, offering additional user-interface interactions or communicating data back to your server (as Google analytics does, for example).</p>
<p>The Iframe approach is useful when you can tell ahead of time the exact size of the embedded widget, and you only want it to display content and not offer any Javascript interactions that occur outside of the Iframe.</p>
 <img src="http://www.techfounder.net/wp-content/plugins/feed-statistics.php?view=1&post_id=461" width="1" height="1" style="display: none;" />
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="Creating embedabble widgets" data-url="http://www.techfounder.net/2010/02/05/creating-embedabble-widgets/"  data-via="erangalperin">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.techfounder.net/2010/02/05/creating-embedabble-widgets/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Common misconceptions in web application development</title>
		<link>http://www.techfounder.net/2008/07/20/common-misconceptions-in-web-application-development/</link>
		<comments>http://www.techfounder.net/2008/07/20/common-misconceptions-in-web-application-development/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 07:13:18 +0000</pubDate>
		<dc:creator>Eran Galperin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://www.techfounder.net/?p=98</guid>
		<description><![CDATA[Over the time I have developed for the web, I have read and heard many assumptions about development practices and technologies. This is my list of common misconceptions in (web) development: 1. OO code is less performant than procedural code The number one argument against OO application design from procedural advocates. This argument is based [...]]]></description>
			<content:encoded><![CDATA[<p>Over the time I have developed for the web, I have read and heard many assumptions about development practices and technologies. This is my list of common misconceptions in (web) development:</p>
<h2>1. OO code is less performant than procedural code</h2>
<p>The number one argument against OO application design from procedural advocates. This argument is based more on intuition than fact. The <a href="http://devzone.zend.com/article/1236-The-Best-Tool-For-The-Job-OO-versus-Procedural-Programming-in-PHP" target="_blank">usual examples</a> pit short procedural code against equivalent OO code in which procedural code comes out triumphant as more terse and performant.<br />
<span id="more-98"></span></p>
<pre class="php"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Procedural, quick and to the point!</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$string</span> = <span style="color: #ff0000;">'hello world'</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$string</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//OO, verbose and ineffecient...</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">class</span> Speaker <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> say<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$string</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$string</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$me</span> = <span style="color: #000000; font-weight: bold;">new</span> Speaker<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$me</span> -&gt; <span style="color: #006600;">say</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'hello world'</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
<p>Actually, this example compares apples to oranges. Both approaches use 'echo' to output a string, only in the OO approach it is wrapped inside a class method. A more appropriate example for the procedural code would be:</p>
<pre class="php"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> say<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$string</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$string</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">say<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'hello string'</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
<p>Which is very similar to the OO code written before. Strong application structure actually does not differ greatly between OO and procedural/functional approaches as my second example suggests, and it is mainly a function of the developer's skill and experience.</p>
<p>OO methodology however gives more language features and scope constructs to deal with code complexities and to handle code reuse, features that would require much more discipline and experience to implement using procedural programming only.</p>
<p>In reality, it is the efficiency of the language parser that will determine performance differences between procedural and OO code. There are no inherent <strong>noticeable</strong> performance differences between both methodologies for <strong>common usage in web applications</strong>. More typically in the web environment, IO operations such as server requests or database queries are the bottlenecks of performance / scalability.</p>
<p>Since it's impossible to know in advance what the bottlenecks will be (you can only make educated guesses), I try to follow the <a title="Wikiwikiweb on Rules of optimization" href="http://c2.com/cgi/wiki?RulesOfOptimization" target="_blank">Rules Of Optimization</a>:</p>
<ol>
<li>First rule of optimization - <strong>Don't</strong></li>
<li>Second rule of optimization - <strong>Don't ... yet</strong></li>
<li>Third rule of optimization - <strong>Profile before optimizing</strong></li>
</ol>
<p>It is much more important to pick a methodology that will promote more maintainable and structured code, as OOP does, to possible minor performance gains. With a well structured design, profiling an application and refactoring slow-performing code is a relatively straightforward process.</p>
<h2>2. The backend is the most important part of development</h2>
<p>I often see web developers treat HTML, CSS and Javascript as second class languages. While HTML and CSS are not programming languages per-se, correct implementation of both in a cross-browser and semantic way requires much experience and skill that I often see lacking in otherwise proficient web developers.</p>
<p>It is not uncommon to relegate implementation of those two markup languages to web designers or  "client-side developers" (which are usually regarded as lower level developers) or to use auto-generating tools for creating markup.</p>
<p><strong>Both approaches are wrong</strong> - the client side is an important aspect of the web development process, especially because of the unique environment a web site or application runs in on the Internet - the browser, which has many different flavours each with its own set of problems and constraints.</p>
<p>Javascript (or DHTML) is another domain expertise which is undervalued and yet has become such a common requirement in today's rich Internet applications. Many web developers coming from a server-side language background have an intrinsic dislike for Javascript because of its weird OO syntax, its difficult debugging scheme and its un-uniform implementation across browsers . I would admit to once have thought the same way, however through necessity I came to like Javascript and now consider it an indispensable skill for a serious web developer.</p>
<p><strong>Don't disrespect the client side languages</strong>. Sometimes the greatest challenges in web development are found there.</p>
<h2>3. Graphical designers are good at user interface design</h2>
<p>* This is more relevant for web applications as opposed to web sites</p>
<p>While there is a connection between graphical design and UI design, graphical designers <strong>do not</strong> naturally make for good UI designers. I can not emphasis this enough. User interface and user experience design is a separate expertise from graphical design. How a user will interact with a site / application is different from how he will view it. It is connected - but not the same.</p>
<p>Quoting <a href="http://en.wikipedia.org/wiki/User_interface_design" target="_blank">wikipedia</a>:</p>
<blockquote><p>Where traditional graphic design seeks to make the object or application physically attractive, the goal of user interface design is to make the user's interaction as simple and efficient as possible</p></blockquote>
<p>Graphical designers with no expertise in UI design tend to prefer aesthetics over usability, and this is only natural as it accentuates their strengths. On the flip side, (web) developers don't usually make for good UI designers either.</p>
<p>UI design is important for creating a usable application. <strong>Make sure the right people are creating it</strong>.</p>
<h2>4. The existence of a superior programming language</h2>
<p>While some programming languages are considered superior to others (higher level, more featured, better syntax etc.), no one language can be considered <strong>the</strong> superior language. Debating that one exists is more a statement of personal preferences than a declaration of actual merit.</p>
<p>All modern languages have roughly the same features and can perform most tasks equally well. Some languages might be more suited to specific problems than others, however no one language does everything better than the others.</p>
<p>Some promote specific languages because of highly acclaimed frameworks developed for them (I'm referring to <a title="Ruby On Rails" href="http://www.rubyonrails.org/" target="_blank">Ruby on Rails</a>, naturally). While this is a more relevant argument, currently all the major languages have at least one serious framework (<a href="http://www.djangoproject.com/" target="_blank">Django</a> for python, <a href="http://framework.zend.com/" target="_blank">Zend Framework</a> / <a href="http://www.cakephp.org/" target="_blank">CakePHP</a> / <a href="http://www.symfony-project.org/" target="_blank">Symphony</a> for PHP).</p>
<p>Use the language you are comfortable with, but <a href="http://www.techfounder.net/2008/05/22/php-versus-the-world/">don't deride others</a> based on your inexperience with them.</p>
<h2>5. XML is more economic than a DB</h2>
<p>Database are notorious for being the major bottleneck for many successful web sites / applications. It is this notoriety that prompts novice developers to seek out alternative persistence layers - and XML is the common alternative.</p>
<p>In general, parsing XML is slower and more resource intensive than querying a database. This is dependent on the complexity of the query, but holds true for 99% of the cases. Furthermore, databases have a much more complete language to fetch, order and manipulate result sets.</p>
<p>XML is a portable format for storing hierarchical data. It is useful for porting data between different databases  or between databases and interfaces. However <strong>XML is not a database</strong>, so don't treat it as one.</p>
<p><em>If you have more to add to this list, I would love to hear about it.<br />
</em></p>
 <img src="http://www.techfounder.net/wp-content/plugins/feed-statistics.php?view=1&post_id=98" width="1" height="1" style="display: none;" />
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="Common misconceptions in web application development" data-url="http://www.techfounder.net/2008/07/20/common-misconceptions-in-web-application-development/"  data-via="erangalperin">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.techfounder.net/2008/07/20/common-misconceptions-in-web-application-development/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>Clearing the floats, overflowing the layout</title>
		<link>http://www.techfounder.net/2008/07/05/clearing-the-floats-overflowing-the-layout/</link>
		<comments>http://www.techfounder.net/2008/07/05/clearing-the-floats-overflowing-the-layout/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 02:38:58 +0000</pubDate>
		<dc:creator>Eran Galperin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://www.techfounder.net/?p=48</guid>
		<description><![CDATA[Float is an often misunderstood CSS property, however when used properly it can be a very useful technique for implementing CSS layouts. Quoting the CSS standards guide at the w3c website: A float is a box that is shifted to the left or right on the current line. ... This property specifies whether a box [...]]]></description>
			<content:encoded><![CDATA[<p>Float is an often misunderstood CSS property, however when used properly it can be a very useful technique for implementing CSS layouts.</p>
<p>Quoting the CSS standards guide at the w3c website:</p>
<blockquote><p>A float is a box that is shifted to the left or right on the current line.</p>
<p>...</p>
<p>This property specifies whether a box should float to the left, right, or not at all.</p></blockquote>
<p>The float property pulls an element out of the normal flow and places it in either the left or right ends of the current line inside its containing block element. Other elements will then wrap around the floated element, providing they have enough space to do so (if the cumulative width of the elements is too wide, they will slide to the next line).</p>
<p><span id="more-48"></span></p>
<p>Floating is a useful technique when an elements needs positioning in the opposite direction of the normal text-flow, or when text needs to be placed near an image.</p>
<p>Examples:</p>
<p><span style="float:right; border:1px solid black;">I am a right-floated span!</span>1. Look to the right.</p>
<p><br style="clear:both;" /></p>
<p><img style="float:left; margin-right:5px;" src="http://www.techfounder.net/wp-content/uploads/2008/07/images.jpg" alt="Floated image" /> 2. This is text wrapped near<br />
a floated image.</p>
<p><br style="clear:both;" /></p>
<p>It's important to emphasis that the floated element will position itself to the side of the <strong>current line</strong>. The most common mistake is to place a right-floated element after the text it's supposed to float near. The intuitive thinking behind this is that the right-floated element appears to the right of the text, and hence should be placed after it (logical for a left-to-right language). However, for the float to be floated to the right of the text it actually needs to be placed before it, since it will be floated for the line it is placed in.</p>
<p>Examples:</p>
<fieldset>
<legend>Same line</legend>
<p><span style="float:right; border:1px solid black;">I am a right-floated span!</span>1. The floated element is written before the text.</p>
</fieldset>
<fieldset>
<legend>Two lines due to misplaced float</legend>
<p>2. The floated element is written after the text.<span style="float:right; border:1px solid black;">I am a right-floated span!</span></p>
</fieldset>
<fieldset>
<legend>Same line</legend>
<p><span style="float:left; border:1px solid black; margin-right:5px; ">I am a right-floated span!</span> <span style="float:right; border:1px solid black; margin-left:5px;">I am a right-floated span!</span> 3. Combination example. Both floats were written before the text.</p>
</fieldset>
<p>The complementary property to 'float' is 'clear'. The 'clear' property cancels a float to either side or both. Using the float image example from before:</p>
<p><img style="float:left; margin-right:5px;" src="http://www.techfounder.net/wp-content/uploads/2008/07/images.jpg" alt="Floated image" /> This is some more text wrapped near<br />
a floated image. If I place an element with<br />
a</p>
<div style="clear:left;">clear property, I cancel the float. (cleared)</div>
<p>The w3c standards declare that the 'clear' property only applies to block elements, however some non-standards compliant browsers ( * cough * IE6) will also apply it to inline elements.</p>
<p>A standard use for the 'clear' property is to prevent a block-element from collapsing if it contains only floats. For example we want to draw a border around two float:</p>
<div style="border:1px solid blue;">
<div style="float:left; height:60px; background-color:red; width:40%; padding:5px;">I float left!</div>
<div style="float:right; height:90px; background-color:red; width:40%; padding:5px;">I float right!</div>
</div>
<p><br style="clear:both;" /><br />
But the border has collapsed, as the floats are outside of the normal flow of elements. To force the div to consider the actual height of the floats, we use another element to clear the float property:</p>
<div style="border:1px solid blue;">
<div style="float:left; height:60px; background-color:red; width:40%; padding:5px;">I float left!</div>
<div style="float:right; height:90px; background-color:red; width:40%; padding:5px;">I float right!</div>
<div style="clear:both; border:1px solid green;">I am an element with a clear property</div>
</div>
<p>There is an alternative technique for achieving the same results which involves using the 'overflow' property in combination with giving the containing element <a href="http://www.satzansatz.de/cssd/onhavinglayout.html" target="_blank">'layout'</a>, which is explained in detail over at quirksmode - <a href="http://www.quirksmode.org/css/clearing.html" target="_blank">Clearing the floats</a>.</p>
<p>Floats have additional uses in more advanced layout techniques, such as <a href="http://www.glish.com/css/2.asp" target="_blank">CSS columns</a> and <a href="http://www.alistapart.com/articles/practicalcss/" target="_blank">CSS table replacements</a>. Along with the 'position' property, they are amongst the most powerful positioning properties for CSS layouts.</p>
<p>For more reference material:<br />
<a href="http://css.maxdesign.com.au/floatutorial/index.htm" target="_blank">maxdesign on floats</a> - extremely comprehensive<br />
<a href="http://www.smashingmagazine.com/2007/05/01/css-float-theory-things-you-should-know/" target="_blank">Smashing Magazine on CSS Float theory</a> - A collection of references to more references <img src='http://www.techfounder.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
<a href="http://www.w3.org/TR/REC-CSS2/visuren.html#floats" target="_blank">The w3c standards guide, Visual formatting model</a></p>
 <img src="http://www.techfounder.net/wp-content/plugins/feed-statistics.php?view=1&post_id=48" width="1" height="1" style="display: none;" />
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="Clearing the floats, overflowing the layout" data-url="http://www.techfounder.net/2008/07/05/clearing-the-floats-overflowing-the-layout/"  data-via="erangalperin">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.techfounder.net/2008/07/05/clearing-the-floats-overflowing-the-layout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML 5 shaping up nicely</title>
		<link>http://www.techfounder.net/2008/06/20/html-5-shaping-up-nicely/</link>
		<comments>http://www.techfounder.net/2008/06/20/html-5-shaping-up-nicely/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 00:11:47 +0000</pubDate>
		<dc:creator>Eran Galperin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[The Webs]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://www.techfounder.net/?p=69</guid>
		<description><![CDATA[Left for dead by many, HTML resurfaced half a year ago when the w3 released a working draft for the next version of this markup language. The draft was recently updated and a document detailing the differences from the previous version was released as well. Having read through the differences document and most of the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ariadne.ac.uk/issue27/web-focus/" target="_blank" title="HTML is dead">Left for dead by many</a>, HTML resurfaced half a year ago when the <a href="http://w3.org" target="_blank" title="World Wide Web Consortium">w3</a> released a <a href="http://www.w3.org/TR/html5/" target="_blank" title="HTML5 working draft">working draft</a> for the next version of this markup language. The draft was recently updated and a <a href="http://www.w3.org/TR/html5-diff/" title="HTML5 vs. HTML4" target="_blank">document detailing the differences</a> from the previous version was released as well.<br />
<span id="more-69"></span><br />
Having read through the differences document and most of the working draft, I feel genuinely excited about the potential of HTML5. They include:</p>
<ul>
<li>Formal support for the <a href="http://en.wikipedia.org/wiki/Canvas_(HTML_element)" target="_blank" title="Wikipedia: CANVAS element">CANVAS drawing API</a>. Already implemented to various degrees in some browsers (excluding the <a href="http://me.eae.net/archive/2005/12/29/canvas-in-ie/" target="_blank" title="Canvas in IE">usual suspect</a>), the CANVAS drawing API is very useful for creating web graphics and interactions programmatically.  (I recently wrote about a <a href="http://www.techfounder.net/2008/05/17/processing-in-javascript/">very interesting port of the Processing language</a> using the Canvas element)</li>
<li>Native <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#dnd">drag-and-drop</a> API (finally!)</li>
<li>Formal API for editing (contentEditable/designMode). Gone are the days of 150kb+ WYSIWYG javascript libraries.</li>
<li>An offline storage API</li>
<li>Browser history API (for fixing broken behavior with modern techniques, ie AJAX)</li>
<li>Server notifications API (standardizing a technique known as <a href="http://en.wikipedia.org/wiki/Comet_(programming)" target="_blank" title="Wikipedia: COMET">COMET</a>).</li>
<li>New attributes such as a global 'href' allowing every element to potentially be a hyperlink.</li>
</ul>
<p>This partial list has enough improvements to make any sane web-developer happy. HTML is definitely heading in the right direction to retain its dominant position as the markup language for the web (its biggest advantage over XHTML being a much more user friendly <a href="http://annevankesteren.nl/2005/04/html5" target="_blank" title="HTML5">error handling</a>).</p>
<p>Now it remains to be seen how long it takes for this proposal to be finalized and implemented.</p>
 <img src="http://www.techfounder.net/wp-content/plugins/feed-statistics.php?view=1&post_id=69" width="1" height="1" style="display: none;" />
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="HTML 5 shaping up nicely" data-url="http://www.techfounder.net/2008/06/20/html-5-shaping-up-nicely/"  data-via="erangalperin">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.techfounder.net/2008/06/20/html-5-shaping-up-nicely/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Standards Compliant RTE</title>
		<link>http://www.techfounder.net/2008/06/09/standards-compliant-rte/</link>
		<comments>http://www.techfounder.net/2008/06/09/standards-compliant-rte/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 14:28:02 +0000</pubDate>
		<dc:creator>Eran Galperin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://www.techfounder.net/?p=61</guid>
		<description><![CDATA[Providing an RTE (Rich Text Editor or WYSIWYG editor) in CMS applications is considered standard nowadays. It allows non-technical content editors to format content and add media without having to learn HTML/CSS or specific CMS markups (such as BBcode or wiki markup). There are several problems with most RTE packages that somewhat limit their effectiveness [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.techfounder.net/wp-content/uploads/2008/06/wymeditor.jpg" alt="WYMEditor - Standards compliant WYSIWYG" class="header" />Providing an RTE (Rich Text Editor or WYSIWYG editor) in CMS applications is considered standard nowadays. It allows non-technical content editors to format content and add media without having to learn HTML/CSS or specific CMS markups (such as BBcode or wiki markup).</p>
<p>There are several problems with most RTE packages that somewhat limit their effectiveness - They produce non-standards compliant HTML markup (using FONT tags and Tables heavily), and they are usually a relatively heavy download (~150kb packed). For a site weighing at around 50kb-60kb integrating a 150kb RTE is a painful decision. </p>
<p><a href="http://www.wymeditor.org/en/" target="_blank" title="WYMEditor">WYMEditor</a> attempts to provide a standards-compliant light-weight alternative, that also shows you the type of markup that is being edited (such as Header, Paragraph etc.). It removes the ability to hand select styles such as colors and borders, instead forcing the editor to use style sheets to separate markup from styling. It's an interesting approach and one that I hope will catch on.</p>
<p>For some more in depth comparison of RTE's read this <a href="http://www.standards-schmandards.com/2007/wysiwyg-editor-test-2/" target="_blank" title="Evaluation of WYSIWYG editors">overview from Standards Schmandards</a>.</p>
 <img src="http://www.techfounder.net/wp-content/plugins/feed-statistics.php?view=1&post_id=61" width="1" height="1" style="display: none;" />
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="Standards Compliant RTE" data-url="http://www.techfounder.net/2008/06/09/standards-compliant-rte/"  data-via="erangalperin">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.techfounder.net/2008/06/09/standards-compliant-rte/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Almost useful IE replacement</title>
		<link>http://www.techfounder.net/2008/06/08/almost-useful-ie-replacement/</link>
		<comments>http://www.techfounder.net/2008/06/08/almost-useful-ie-replacement/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 01:19:37 +0000</pubDate>
		<dc:creator>Eran Galperin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[techfounder]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://www.techfounder.net/?p=60</guid>
		<description><![CDATA[I stumbled upon a tool by the name of IETester today, that is supposed to render websites in different IE engines from version 5.5 to 8 beta. It appears to be working quite well, allowing to open multiple tabs of different IE versions. Unfortunately its Javascript support is too limited to be of real use [...]]]></description>
			<content:encoded><![CDATA[<p>I stumbled upon a tool by the name of IETester today, that is supposed to render websites in different IE engines from version 5.5 to 8 beta. It appears to be working quite well, allowing to open multiple tabs of different IE versions. Unfortunately its Javascript support is too limited to be of real use for serious application development.</p>
<p>Still, a nice tool for web designers wishing to test their HTML and CSS layouts against several generations of IE, without having to resort to hacking multiple installations of different versions (such as <a href="http://tredosoft.com/Multiple_IE">multipleIE</a>).</p>
<p><a href="http://www.my-debugbar.com/wiki/IETester/HomePage">IETester</a> [via <a href="http://lifehacker.com/395353/ietester-renders-sites-like-internet-explorer-55-through-8">LifeHacker</a>]</p>
 <img src="http://www.techfounder.net/wp-content/plugins/feed-statistics.php?view=1&post_id=60" width="1" height="1" style="display: none;" />
	<div style="">
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="Almost useful IE replacement" data-url="http://www.techfounder.net/2008/06/08/almost-useful-ie-replacement/"  data-via="erangalperin">Tweet</a>
	</div>
	<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.techfounder.net/2008/06/08/almost-useful-ie-replacement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

