<?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>thought snippets &#187; html</title>
	<atom:link href="http://blog.u-blue.com/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.u-blue.com</link>
	<description>a little bit of everything</description>
	<lastBuildDate>Tue, 08 Nov 2011 03:42:46 +0000</lastBuildDate>
	<language>TH</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>จากตาราง เปลี่ยนเป็น Div</title>
		<link>http://blog.u-blue.com/2009/05/11/from-table-to-div/</link>
		<comments>http://blog.u-blue.com/2009/05/11/from-table-to-div/#comments</comments>
		<pubDate>Mon, 11 May 2009 07:34:40 +0000</pubDate>
		<dc:creator>nice</dc:creator>
				<category><![CDATA[webdev]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://blog.u-blue.com/?p=96</guid>
		<description><![CDATA[วิธีง่ายๆที่จะเปลี่ยนจากการเขียน html layout โดยใช้ตารางมาเป็น css/div layout สำหรับคนที่กำลังลังเลที่จะใช้ css แทนตารางแบบเดิมๆ ก่อนอื่นดูตารางก่อน โค้ทของตาราง This is Header Main Menu -Menu1 Content goes here! This is content! ดูแล้วก็ง่ายๆ ตามสไตล์ที่คุ้นเคย แต่ดูแล้วยุ่งยากใจพิลึก ทีนี้เราจะจับเจ้า layout ที่คุ้นเคยนี้แหละมาเขียนเป็น css ออกมาจะหน้าตาเป็นแบบนี้ ก็คล้ายๆกัน ดูเผินๆก็ไม่มีอะไรต่าง แต่ทีนี้มาดูโค้ทกันบ้าง ส่วนของ html จะเห็นว่าโค้ท html จะไม่ยุ่งยากเหมือนตอนทำตาราง ซึ่ง search engine จะชอบมากกว่า This is Header Main Menu -Menu1 Content goes here! This is content! ]]></description>
			<content:encoded><![CDATA[<p>วิธีง่ายๆที่จะเปลี่ยนจากการเขียน html layout โดยใช้ตารางมาเป็น css/div layout สำหรับคนที่กำลังลังเลที่จะใช้ css แทนตารางแบบเดิมๆ</p>
<p>ก่อนอื่นดูตารางก่อน</p>
<div id="attachment_109" class="wp-caption alignnone" style="width: 379px"><a href="http://blog.u-blue.com/wp-content/uploads/2010/01/table1.png"><img src="http://blog.u-blue.com/wp-content/uploads/2010/01/table1.png" alt="" title="table" width="369" height="83" class="size-full wp-image-109" /></a><p class="wp-caption-text">Table Layout</p></div>
<p>โค้ทของตาราง</p>
<pre class="brush:xml">
<table width="350" align="center">
<tbody>
<tr>
<td colspan="2" align="center"  bgcolor="#eeeeee">
This is Header</td>
</tr>
<tr>
<td width="100" align="left" valign="top"  bgcolor="#999999">
Main Menu
-Menu1</td>
<td align="left" valign="top"  bgcolor="#cccccc">
Content goes here!
This is content!</td>
</tr>
</tbody>
</table>
</pre>
<p>ดูแล้วก็ง่ายๆ ตามสไตล์ที่คุ้นเคย แต่ดูแล้วยุ่งยากใจพิลึก ทีนี้เราจะจับเจ้า layout ที่คุ้นเคยนี้แหละมาเขียนเป็น css<br />
<span id="more-96"></span><br />
ออกมาจะหน้าตาเป็นแบบนี้</p>
<div id="attachment_110" class="wp-caption alignnone" style="width: 380px"><a href="http://blog.u-blue.com/wp-content/uploads/2010/01/div.png"><img src="http://blog.u-blue.com/wp-content/uploads/2010/01/div.png" alt="" title="div" width="370" height="70" class="size-full wp-image-110" /></a><p class="wp-caption-text">Css Div Layout</p></div>
<p>ก็คล้ายๆกัน ดูเผินๆก็ไม่มีอะไรต่าง แต่ทีนี้มาดูโค้ทกันบ้าง<br />
ส่วนของ html จะเห็นว่าโค้ท html จะไม่ยุ่งยากเหมือนตอนทำตาราง ซึ่ง search engine จะชอบมากกว่า</p>
<pre class="brush:xml">
<div id="container">
<div id="header">This is Header</div>
<div id="menu">Main Menu
-Menu1</div>
<div id="content">Content goes here!
This is content!</div>
</div>
</pre>
<p>ส่วนของ css</p>
<pre class="brush:css">
div#container{
	width:350px;
	margin:0 auto;
	background:#cccccc;
}
div#header{
	text-align:center;
	background: #eeeeee;
}
div#menu{
	width:100px;
	float:left;
	background: #999999;
}
div#content{
	width:250px;
	float:left;
	background: #cccccc;
}</pre>
<p>สองส่วนนี้เท่านั้น เป็นอันจบ ไม่เจ็บปวดอย่างที่คิด ตอนเอามาประกอบรวมกันก็สามารถทำได้ 2 แบบ คือ</p>
<ol>
<li>ใส่โค้ท css ไว้ในส่วน head ของ html ใต้ tag
<pre class="brush:xml">
<style type="text/css">...</style>
</pre>
</li>
<li>แยกโค้ท css ไว้ในไฟล์ .css แล้วทำลิงค์ไปหา โดยใช้ tag
<pre class="brush:xml">
<link rel='stylesheet' href='file.css' type='text/css' media='all' /></pre>
</li>
</ol>
<p>ซึ่งการแยกโค้ทออกไปนั้นมีประโยชน์หลายอย่าง เช่น</p>
<ol>
<li>ลดเวลาโหลดหน้าต่อๆไป ประหยัดแบนด์วิธ เนื่องจากบราวเซอร์จะเก็บ cache ของไฟล์ css ไว้ในเครื่อง</li>
<li>สามารถแก้ไขได้ง่ายถ้านำไปใช้หลายๆหน้า html เพราะจะแก้ที่ไฟล์ css ที่เดียว</li>
<li>อีกทั้งในส่วน media=&#8221;xxx&#8221; นั้นสามารถกำหนดได้หลายอย่าง เช่น print,screen เพื่อเปลี่ยน layout สำหรับการดูแบบต่างๆ</li>
</ol>
<p>การทำตารางไปเป็น div นั้นเป็นแค่การเริ่มต้นให้เห็นภายเท่านั้นว่าถ้าไม่มีตารางจะทำ layout อย่างไร ซึ่งถ้าใช้จริงๆแล้วตัว css จะสามารถใช้ทำหน้าเว็บได้อย่างอิสระมากกว่าใช้ตาราง และ powerful กว่ามากในแง่ของการออกแบบ ซึ่งมันแจ่มมาก และหากใช้คล่องๆแล้วจะพบว่ามันง่ายกว่าใช้ table มากมายนัก</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.u-blue.com/2009/05/11/from-table-to-div/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

