{"id":517,"date":"2007-01-16T09:47:13","date_gmt":"2007-01-16T09:47:13","guid":{"rendered":"http:\/\/www.intmath.com\/blog\/?p=517"},"modified":"2019-07-07T15:01:04","modified_gmt":"2019-07-07T07:01:04","slug":"tidying-css-and-xhtml-a-case-study-tutorial","status":"publish","type":"post","link":"https:\/\/www.intmath.com\/blog\/computers\/tidying-css-and-xhtml-a-case-study-tutorial-517","title":{"rendered":"Tidying CSS and XHTML - a case study tutorial"},"content":{"rendered":"<p>One of my readers used my Adding Feeds With CGFeedread tutorial [no longer available] and got it to work with some Yahoo! news and other feeds. Dan (the reader) is using a WordPress template for consistency across his site.<\/p>\n<p>I gave him some feedback about the design being broken in Firefox and I detected some desperation in his request for help.<\/p>\n<p>So here is a quick overview of what I did for him. The final result needs a few bits of tidying up, but I will leave that to Dan.<\/p>\n<h2>The Original<\/h2>\n<p>The original page was a confusing mix of tables and DIVs and it was very difficult to figure out what was supposed to be going on. It worked OK in IE, but not in Forefox. It did not validate using the W3C validator.<\/p>\n<h2>The Fixed Version<\/h2>\n<p>Dan had already changed the doctype to the correct XHTML type.<\/p>\n<pre>&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\"\r\n    \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">\r\n&lt;html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\r\n  &lt;head profile=\"http:\/\/gmpg.org\/xfn\/11\"><\/pre>\n<p>Next job was to clear out all of the <strong>tables<\/strong>, so we were left with <strong>DIVs<\/strong> only.<\/p>\n<p>This was the desired layout. Simple, standards compliant, and works in both IE and Firefox:<\/p>\n<p><img id=\"image519\" src=\"\/blog\/wp-content\/images\/2007\/01\/layout.gif\" alt=\"Layout\" \/><\/p>\n<p>With a simpler layout, I could remove mountains of unnecessary CSS coding. The XHTML file is a lot simpler, too. My general process when doing this exercise is to strip out ALL of the CSS and put classes and id's back one at a time into the CSS file. This helps to identify where things are going funny.<\/p>\n<p>Here's how the CSS looks for the menu items and the 3 columns:<\/p>\n<pre>        #menus {\r\n          padding:145px 70px 0 20px;\r\n          font-size:1.2em;\r\n        }\r\n        #leftCol {\r\n         padding-left:20px;\r\n         float:left;\r\n         width:160px;\r\n        } \r\n        #cgfeed {\r\n         width:360px;\r\n         float:left;\r\n        }\r\n        #rightCol {\r\n         width:180px; \r\n         float:left; \r\n         padding-left:20px;\r\n        }\r\n<\/pre>\n<p>Next, I had to ensure <strong>standards compliance<\/strong>. The following do not belong in XHTML: &lt;br> and &lt;img ... >. You have to close them properly, as follows: <\/p>\n<pre>&lt;br \/> &lt;img ... \/><\/pre>\n<p>There were several other things like mismatched DIVs to sort out. The &lt;font> tag is deprecated and so they all had to go. Finally it was starting to look good.<\/p>\n<p>Next step involved some lining up, tidying up and fixing font sizes. It's not perfect yet, but as I said, I will leave the final touches to Dan.<\/p>\n<p class=\"alt\">See the <a href=\"https:\/\/www.intmath.com\/blog\/computers\/tidying-css-and-xhtml-a-case-study-tutorial-517#comments\" id=\"comms\">3 Comments<\/a> below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A reader was having lots of troubles on a page that had a mix of tables and DIVs. I explain here what I did to fix it, and why.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mo_disable_npp":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/posts\/517"}],"collection":[{"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/comments?post=517"}],"version-history":[{"count":1,"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/posts\/517\/revisions"}],"predecessor-version":[{"id":12050,"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/posts\/517\/revisions\/12050"}],"wp:attachment":[{"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/media?parent=517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/categories?post=517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/tags?post=517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}