Deprecated: Function create_function() is deprecated in /home2/blogwebhostingbu/public_html/wp-content/plugins/facebook-like-box-responsive/facebook-like-box.php on line 29
{"id":1562,"date":"2011-05-15T21:46:47","date_gmt":"2011-05-15T21:46:47","guid":{"rendered":"http:\/\/www.webhostingbuzz.com\/blog\/?p=1562"},"modified":"2011-05-15T21:46:47","modified_gmt":"2011-05-15T21:46:47","slug":"use-css-properly-for-efficient-web-sites","status":"publish","type":"post","link":"https:\/\/blog.webhostingbuzz.com\/2011\/05\/15\/use-css-properly-for-efficient-web-sites\/","title":{"rendered":"Use CSS properly for efficient web sites"},"content":{"rendered":"

CSS (Cascading Style Sheets) was one of the best things ever to happen to web site development. CSS makes it easier to define the look and format of web pages, and it enables layout and behaviour not possible with HTML alone. I used CSS even on my first web site, in spite of limited browser support, and would never consider coding a site without it. <\/p>\n

I’m surprised at how many web developers still write CSS into each web page. This can be seen by viewing the HTML of the pages, easily done with the View > Source command in Internet Explorer, View > Page Source in Firefox, or similar commands in other browsers. Many sites still write their style declarations into the HEAD of each page. This is not an efficient way to use CSS, and is certainly not my preferred method. Here’s an example of this poor practice:<\/p>\n

<head<\/span><\/a>><\/span>
\n<
title<\/span><\/a>><\/span>CSS Example<\/<\/span>title<\/span><\/a>><\/span>
\n<
style<\/span><\/a> TYPE<\/span>=<\/span>"text\/css"<\/span>><\/span>
\n  H1 { font-size: x-large; color: red }
\n  H2 { font-size: large; color: blue }
\n<\/<\/span>
style<\/span><\/a>><\/span>
\n<\/<\/span>
head<\/span><\/a>><\/span><\/div><\/div>\n

Even worse, I see sites that write their styles as HTML attributes in each element on the web page, e.g.:<\/p>\n

<p<\/span><\/a> "style=color: #090; line-height: 1.2"<\/span>><\/div><\/div>\n

What a waste of great potential.<\/p>\n

CSS is more powerful if you use an external stylesheet. If you want to make all H1 headers larger or a different colour, or change the layout of the navigation bar, those properties may be altered for all page of the site by editing just a single stylesheet. To me, this is one of the great benefits of CSS: small edits in a single file can change the look of the entire web site.<\/p>\n

You might want to employ more than one stylesheet for the site, perhaps one as default for most browsers and another targetting mobile browsers. You may want all layout in one stylesheet and all font properties in another. No problem. A web page can link to and load multiple stylesheets.<\/p>\n

To apply an external stylesheet to a web page, insert a “link” element in the HTML HEAD, e.g.:<\/p>\n

<link<\/span><\/a> rel<\/span>=<\/span>"stylesheet"<\/span> type<\/span>=<\/span>"text\/css"<\/span> href<\/span>=<\/span>"docs\/Basic.css"<\/span>><\/div><\/div>\n

I created a web site for a small business. One day the client asked me to change the site’s colour theme. This involved the colours of page titles, various levels of text headings, highlighted text, corporate logo on every page, and other elements. Had this information been coded into each page, this would have been a lot of work. As it was, all colour specifications were in a single site-wide stylesheet.<\/p>\n

I even had the logo images called from within the stylesheet, so once I had altered the logo colour in graphics software, replacing the logo and changing all element colours was simple. I just changed the colour values in the CSS declarations. A few quick edits to that single .css file and the entire site changed. By using CSS properly when I designed the site, I saved much work later on.<\/link><\/p>\n","protected":false},"excerpt":{"rendered":"

CSS (Cascading Style Sheets) was one of the best things ever to happen to web site development. CSS makes it easier to define the look and format of web pages, and it enables layout and behaviour not possible with HTML alone. I used CSS even on my first web site, in spite of limited browser […]<\/p>\n","protected":false},"author":134,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"yoast_head":"\nUse CSS properly for efficient web sites - WebHostingBuzz US Blog<\/title>\n<link rel=\"canonical\" href=\"https:\/\/www.webhostingbuzz.com\/blog\/2011\/05\/15\/use-css-properly-for-efficient-web-sites\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Use CSS properly for efficient web sites - WebHostingBuzz US Blog\" \/>\n<meta property=\"og:description\" content=\"CSS (Cascading Style Sheets) was one of the best things ever to happen to web site development. CSS makes it easier to define the look and format of web pages, and it enables layout and behaviour not possible with HTML alone. I used CSS even on my first web site, in spite of limited browser […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhostingbuzz.com\/blog\/2011\/05\/15\/use-css-properly-for-efficient-web-sites\/\" \/>\n<meta property=\"og:site_name\" content=\"WebHostingBuzz US Blog\" \/>\n<meta property=\"article:published_time\" content=\"2011-05-15T21:46:47+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"2 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webhostingbuzz.com\/blog\/#website\",\"url\":\"https:\/\/www.webhostingbuzz.com\/blog\/\",\"name\":\"WebHostingBuzz US Blog\",\"description\":\"Hosting, hosting, more hosting and a little of everything else\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.webhostingbuzz.com\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webhostingbuzz.com\/blog\/2011\/05\/15\/use-css-properly-for-efficient-web-sites\/#webpage\",\"url\":\"https:\/\/www.webhostingbuzz.com\/blog\/2011\/05\/15\/use-css-properly-for-efficient-web-sites\/\",\"name\":\"Use CSS properly for efficient web sites - WebHostingBuzz US Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhostingbuzz.com\/blog\/#website\"},\"datePublished\":\"2011-05-15T21:46:47+00:00\",\"dateModified\":\"2011-05-15T21:46:47+00:00\",\"author\":{\"@id\":\"https:\/\/www.webhostingbuzz.com\/blog\/#\/schema\/person\/b4eacaf6cae2f9666e137b91e8d83a71\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.webhostingbuzz.com\/blog\/2011\/05\/15\/use-css-properly-for-efficient-web-sites\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webhostingbuzz.com\/blog\/2011\/05\/15\/use-css-properly-for-efficient-web-sites\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webhostingbuzz.com\/blog\/2011\/05\/15\/use-css-properly-for-efficient-web-sites\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webhostingbuzz.com\/blog\/2011\/05\/15\/use-css-properly-for-efficient-web-sites\/\",\"url\":\"https:\/\/www.webhostingbuzz.com\/blog\/2011\/05\/15\/use-css-properly-for-efficient-web-sites\/\",\"name\":\"Use CSS properly for efficient web sites\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webhostingbuzz.com\/blog\/#\/schema\/person\/b4eacaf6cae2f9666e137b91e8d83a71\",\"name\":\"Alan Burns\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.webhostingbuzz.com\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e051b4a10a90049d6e913ff8ab111a1a?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e051b4a10a90049d6e913ff8ab111a1a?s=96&r=g\",\"caption\":\"Alan Burns\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/blog.webhostingbuzz.com\/wp-json\/wp\/v2\/posts\/1562"}],"collection":[{"href":"https:\/\/blog.webhostingbuzz.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.webhostingbuzz.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.webhostingbuzz.com\/wp-json\/wp\/v2\/users\/134"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.webhostingbuzz.com\/wp-json\/wp\/v2\/comments?post=1562"}],"version-history":[{"count":0,"href":"https:\/\/blog.webhostingbuzz.com\/wp-json\/wp\/v2\/posts\/1562\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.webhostingbuzz.com\/wp-json\/wp\/v2\/media?parent=1562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.webhostingbuzz.com\/wp-json\/wp\/v2\/categories?post=1562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.webhostingbuzz.com\/wp-json\/wp\/v2\/tags?post=1562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}