<?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>WebDev77&#187; oop</title>
	<atom:link href="http://www.webdev77.com/tag/oop/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webdev77.com</link>
	<description>WebDev77, your online source for news, comments and articles on Web Hosting, Internet marketing, SEO techniques and Web development and design.</description>
	<lastBuildDate>Sat, 04 Apr 2009 00:05:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>CSS tags &#8211; id vs. class</title>
		<link>http://www.webdev77.com/css-tags-id-class/</link>
		<comments>http://www.webdev77.com/css-tags-id-class/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 02:35:37 +0000</pubDate>
		<dc:creator>Bogdan Enache</dc:creator>
				<category><![CDATA[Web Dev & Design]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[class template]]></category>
		<category><![CDATA[css tags]]></category>
		<category><![CDATA[object oriented programming]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://www.webdev77.com/?p=28</guid>
		<description><![CDATA[The `tags war` To class or not to class? This is the question &#8230; for this blog entry. Let&#8217;s try and find the answer with the help of an analogy to OOP. CSS and OOP? I reckon most of you already know what OOP stands for but for those who don&#8217;t, OOP stands for Object [...]]]></description>
			<content:encoded><![CDATA[<h3>The `tags war`</h3>
<p>To class or not to class? This is the question &#8230; for this blog entry. Let&#8217;s try and find the answer with the help of an analogy to OOP.</p>
<h3>CSS and OOP?</h3>
<p>I reckon most of you already know what OOP stands for but for those who don&#8217;t, OOP stands for Object Oriented Programming &#8211; the classes-objects-inheritance concepts used in code writing and code design with the ultimate goal of maximizing code reuse. So, what do CSS tags and Object Oriented Programming have in common? And most important, how can OOP concepts help us decide which tag is better suited for the job. At a first glance, class is a reserved word in both languages, so maybe we can start from there. <img src='http://www.webdev77.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>So, class is class?</h3>
<p>Coincidence or not, the CSS class has similar behaviour with the classes from OO programming languages. Let&#8217;s say you want all the h3 tagged text on the page to be underlined. You could write a CSS class for h3 and specify &#8220;text-decoration: underline;&#8221;. Each time you will use the h3 tag the text formatting will include an underline. So basically you are using the CSS class &#8220;template&#8221; to create multiple instances of h3 text and that is exactly what OOP classes are (among other things): templates for objects.</p>
<h3>Then id is an object?</h3>
<p>The CSS id tag is still used as a class in order to define the &#8220;shape&#8221; of the element that will have the id assigned. However, the id tag is usually used to pinpoint an unique object on the web page. Tracking elements by unique ids is a useful technique (i.e. when using Javascript methods to update or modify elements, when parsing POST form variables in PHP, etc.). Think of the id tag as a class with a single object or the class/object concept merged. It&#8217;s like that philosophical question: what is the shape of a chair? When you think of a chair you think about the shape or the object itself?</p>
<h3>Conclusions</h3>
<p>The answer to our initial question is now simple: use the CSS <u>class</u> tag when you need to tag or modify the format of more than 1 element in the web page and use the CSS <u>id</u> tag when you need to pinpoint to a specific element in the web page (something like the &#8220;You are here!&#8221; signs in the shopping malls).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdev77.com/css-tags-id-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

