建立無表格網站的原因和原則 譯文_經驗交流

來源:互聯網
上載者:User
In a time of web developers who just like to say that 'Tables are Evil' and can't (or won't) explain why, this article will attempt to give you some solid reasons that people create tableless designs. Included are six major benefits of creating tableless sites, and how to sell your desire to alter your website to a resistant manager.
一時間,網頁設計師們都在說:表格是魔鬼!但是他們並不能講出其中的原因。那麼在這裡,我將給你一些具令人信服的理由,表明為什麼人們不願意使用表格來建立網頁。其中包括建立無表格網站的四個好處,以及如何將網站轉變為經久不衰的“統治者”,並將它推銷出去。
Let's begin with the benefits of a tableless layout. These are only in the order that I feel they should go in, some things are more important to other people, so rank them as you will.
讓我們先從表格版面配置的好處開始講起。之所以把它列在其中是因為他對很多人是至關重要的。
Forces You To Write Well-Formed Code
迫使你書寫格式嚴謹的代碼
You cannot have a properly made tableless layout, and use improper and non-standard code. Well, let me correct that - you can (technically you can do it) but it defeats the whole purpose. When you are creating a tableless design, you should be using standards compliant code. I think that anything that makes you get into the habit of always writing clean code is a good thing.
你不可能使用不合適的或不標準的代碼來進行無表布局。讓我更正一下——你可以(僅從技術角度來說),但是,這樣做會使得所有目標落空。當你進行無表設計時,你必須使用一套合適的、標準的代碼。我認為,能夠讓你養成一個好的編程習慣的所有事情都是好事情。
Faster Loading Time
下載更快
This is absolutely a benfit of a tableless layout, and for several reasons. First, on a fundamental level - tables load slowly. For the most part, unless you set the height and width of your table elements, all the text has to be loaded and rendered BEFORE the table sizes itself to the page. Of course, this is what so many people loved about tables isn't it? The fact that they were so easily sizeable. The downside is how much more time they take to load.
無表布局非常有好處,其中包含下面這幾個理由:1、從基本原理上講,使用表格版面配置將減緩下載速度;更重要的一點,無論你怎樣設定表格元素的高度和寬度,表格內的所有元素都將在載入表格之前載入,這可能是很多人熱衷表格版面配置的原因吧!事實上,表格的尺寸一般都很大,所以它們反而會載入更長的時間。我們不能忽視它的下載時間。
Okay, so the solution to that loading time is to set all the values explicitly, right? So now we see another downside. Code clutter that increases loading time. First of all, just by themselves, tables take a lot of code. How many td open and close tags does your average table based layout have? Tons. Having to set all the values explicitly only adds to the page size and loading time. There are many experiments that have been done on this topic, I'll point you toward this one that StopDesign did on a remake of the Microsoft website from a tablebased site to a tableless layout. That remake showed a 62% file size reduction of the site, and using their average hits per month for the Microsoft site, calculated that Microsoft would be saving 924 GIGS in bandwidth per day, and 329 Terabytes of bandwidth per year. For any company that pays for bandwidth, these things are important.
因此,我們必須把所有的值設定清楚,從而減少下載的時間。接下來讓我們看看其它的缺點吧:代碼的混亂會增加載入的時間。首先,表格本身包含了大量的代碼,你可以數數看其中包含了幾個“td”開始和結束標籤,我想應該是很多吧。為了把它們設定的清楚一點,必須增加網頁的尺寸從而導致下載時間延長。關於這個主題,我們已進行了多次實驗。盡量不要再使用表格進行布局了,看看微軟的做法吧,他們原來是使用表格版面配置的已經開始使用非表格版面配置了。研究表明,這種做法為該網站節省了62%的空間大小;通過每月平均點擊率計算,微軟將每天節省924 GIGS的頻寬,一年將節省329Terabytes的頻寬。對於任何一家頻寬佔用較大的公司,這樣做都是非常必要的。
Easier to Read Code
增加代碼的易讀性
If you are using standard code, semantic document conventions, and a tableless layout, your code can be so clean that it looks practically like just regular text with a few extra symbols.
如果使用的是標準代碼,標準語義文檔和非表格版面配置,那麼你的代碼將看上去非常清楚,簡直就如同一個帶有一些特殊符號的慣用文本。
That is a great benefit because it not only makes it easier for you to update, but it makes it easier for a non-technical user to make small alterations to. Additionally, if you work as a web developer in a more freelance capacity, it is common for there to be a full-time web developer who has to maintain that site. Clean and simple to read code makes that a easy transition. We like it when people leave us easy to understand code, right? Let's return the favor.
使用非表格版面配置的好處不僅在於方便你對網頁進行更新,而且還可以使非轉業的人對其進行細微地修改和轉換。另外,如果你是一個自由職業的網頁設計師,你也可以讓專業網頁設計師記住你的網站。代碼的簡明性可以使代碼轉化工作變得非常容易。我們都希望代碼開發人員們為我們留下的是簡單的代碼,所以,當我們書寫代碼時,也考慮考慮這點吧。
Print Alternate Views
方便的樣式定義
When you create a page using a table-layout, you are rather unfortunately locked into a certain layout. Developers who have created table-based websites, as most of us have at some point - particularly if you were in the the industry before the big tableless movement, know that you often have to create a separate printable version of your pages. This can be, needless to say, quite tiresome.
當我們使用表格版面配置建立網頁時,你不應該拘泥於一種特定的布局方法。使用表格版面配置的開發人員,如同我們當中的大多數人一樣,必須要注意一點,如果你是在“網頁設計無表格化”運動之前從事設計工作的,你必須為每張網頁建立一種獨立的樣式,這樣做非常繁瑣。
Ease of printing style control is a huge benefit with a tableless layout. You can easily create a single new printing style that applies to all your pages, instead of making them individually. That alone is a huge time saver, but there is more.
簡易的輸出樣式控制是無表化布局的一個巨大優勢。你可以輕鬆地建立一種簡單的全新布局,並將其運用到所有網頁中,而無需對每個頁面都設計一套樣式。這無疑會節省巨大的時間。
While you can control all elements with this approach, the biggest key is organization of information within the page itself. Using the example, let's assume that the display order we want all our pages to print using the following order: The page header first, the content next, the special news after that, then the link list, and then the footer. However! We still want it to display as it would normally when viewing (meaning the header at the top, the links on the left, content in the middle, news on the right, and footer at the bottom). With a table-based layout, you would have to create a new page to do that special printing organization because the print style will read your columns left to right. With a table-less layout, you are not bound by this. You can order the content in your page however you like, and still control the way it looks... all by using the CSS only !
當你使用這種方法控制所有元素時,那麼首先要考慮的一個關鍵點就是:如何將頁面本身的所有資訊有效地組織起來。讓我們設想一下下面的排序方式:首先是頁首,接下來是內容,然後是特定的新聞資訊和連結清單,最後是頁尾。然而,我們仍然希望它按照我們正常的瀏覽習慣進行顯示(即:頁首在最頂端;連結清單在中間左端;內容在中間;新聞在中間右端;頁尾在最底端)。如果你使用表格版面配置的話,那麼你必須重新建立一個頁面,因為表格的讀取順序是從左往右的;但是,如果你使用了無表化布局,那你就不會被這種形式所束縛。你可以隨心所欲的擺放內容的位置並很好的對它進行控制。而只需要使用CSS便可以順利實現上述的目的。
Additionally, because we can put the content in whatever order we want in the HTML, and then move the content blocks around for website viewing using CSS - we can have ultimate control over presentation.
另外,因為我們可以使用CSS將所有內容或部分內容放在HTML頁面中的任何地方,因此,我們可以對它的表現方式做出隨意的控制。
That is very important because the clean code, and ability to alter presentation, means that your site can be viewable by someone on a small mobile phone screen。The flexibilty and organization leads to being able to create a powerful website that takes advantage of some of the possibilities with XHTML.
因為代碼的精簡是如此的重要,它可以隨意的控制內容的表達方式和位置,因此,即使是在一個手機螢幕上,也可以很輕鬆的展現你的網頁。我們可以利用XHTML的擴充性和組織性來建立優秀的網站。
Search Engine Optimization
搜尋引擎最佳化
Due to the fact that you can organize your most important content at the top of your page, without affecting the layout, your page can be better optimized for search engines. For instance, say that I have a navigation bar on the left side of the page that lists tons of parts of the site that are actually great keywords. I could move that navigation bar code higher up in my actual HTML, without changing the layout, because I'm using the CSS to position the navigation where I want it.
因為你可以使用無表化布局將最重要的內容放在頁面頂端,而這樣做又不會影響整個布局,那麼你的頁面可以最大限度的執行搜尋引擎最佳化。舉個例子來說,我在頁面的左邊部分放置了導航條,上面寫了一些關注率非常高的關鍵詞。因此我可以把導航條代碼寫在HTML代碼之前而不影響整個頁面配置。因為我是使用CSS來調整它的位置的。
Those search engines can also more clearly find common words throughout your document without having to filter through code. Search engines prioritize websites that have a higher content to code ratio, so putting all your style elements into your external CSS stylesheet makes your site highly content based to a search engine. Tableless layouts, as previously mentioned, decrease page size and loading time - another bonus to search engines.
搜尋引擎不需要過濾代碼就可以找到將整個文檔的通用關鍵字。搜尋引擎會搜尋那些內容比例所佔頁面比例較多的頁面,因此,把樣式元素放到外部樣式表中,這樣可以使內容凸顯出來。上描提到的無表化布局,明顯的減少了頁面尺寸和下載時間,可以更大限度的利用搜尋引擎。
Presentation Flexibility
全方位適應性
Making changes to a CSS based Tableless layout is simple. You can alter the CSS file only, changing as many styles and graphics as you want. The affects cascade through all the pages on your website, and eliminate the need for manually updating many pages.
以CSS為基礎的無表化布局是非常簡易的一種方法。你可以通過轉變CSS檔案來更改你所希望的樣式和圖片。在整個網站中使用層疊樣式表可以減少日常頁面更新的工作量。
For one of the best known examples of how powerful presentation can be, you can visit the CSS Zen Garden and navigate through the 'Select a Design' links to see the differences. Each of the different designs uses exactly the same HTML file content. The only thing that changes is the CSS file for each one.
你可以訪問一下著名的網站:CSS Zen Garden,在整個頁面配置上,它堪稱經典。你可以通過點選導航條上的“Select a Design”來查看不同的布局風格。每個不同的設計風格都使用了完全一致的HTML內容。它僅通過使用不同的CSS來改變HTML的內容。
Selling Yourself On Standards
用不同的標準來推銷你自己
Sometimes knowing how to code for standards, and create flexible tableless layouts is not enough. There are some web designers who meet with difficulties from their management. Most often those difficulties are rooted in the management being unaware of the benefits of using tableless content and CSS driven layout.
這裡要說的是:使用標準的代碼,建立可擴充的無表格版面配置還是不夠的。一些網站設計師還是遇到了很多網站管理上的困難。在大多數情況下,這都是由於忽略了無表化布局的內容以及CSS布局方式而導致的。
If you want to design for standards, but you work for a company that is not very forward-thinking in allowing you the time to work on the changes -- try this: Make them think about their pocket-book. Point out the cost saving benefits.
如果你希望進行標準化設計,但是你所在的公司不允許這麼做,因為可能會耽誤時間。那麼你可以這樣做:把它們記載袖珍筆記本中,並指出哪裡可以節省成本。
For instance, try grabbing a single page of existing code. Clean it up to standards. Compare the page size to before (including image optimization), and count the difference in bytes saved. Multiply that across the number of site pages, and the number of days per month. Then explain to them the amount of bandwidth cost saved monthly if this was done across the whole site. If that isn't enough, show them how quickly you can make changes to a website once it is CSS driven, and push the idea that you will be able to change the site more rapidly when there are needed updates, and you will have more time to focus on adding in new functionality to the site - instead of spending your time doing maintenance.
舉個例子來說,儘可能的抓取現有的字碼頁面,並將其中的代碼以簡明標準的代碼格式重新書寫。然後,比較前後兩者頁面的尺寸差異(包括對圖片的最佳化),計算尺寸差值。然後,說明一下,如果按照新的布局方式,每個月可以省去多少頻寬成本。如果這樣還不夠,你可以再具體說明一下,如果用CSS布局會提高多少下載速度;並且,在頁面更新的時候,可以省去多少更新時間。這樣一來,你就可以把時間省下來用於提升網站的功能性——這樣就省去了大部分維護的時間。
Summary
總結
Hopefully, this little article will serve as a way to get you started on understanding why to use a tableless layout, what the benefits are, and you can easily take a look at Layout Gala and download just 1, or all 40 of the tableless layout examples to get you started. However, the best step toward moving to a tableless design is to slowly move your website toward a standard compliant version first, before you get rid of the tables. To get to that point, study as much on CSS as you can, read through the articles here and elsewhere on the web, and moving from table layouts to tableless will be just a matter of time.
寫這篇文章的目的在於,讓大家能夠大小使用無表化布局的疑慮,並開始使用這種方式進行布局。這裡有一條捷徑,你可以直接在Layout Gala網站上下載現成的40個模版案例來進行布局。在你放棄使用表格之前,你應該儘可能放慢網站的無表化進程。你應該充分學習CSS技術,讀完這篇文章以及網站上其他相關的文章之後,你製作無表布局的網站只是時間問題了。
  • 相關文章

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.