Merry Christmas and Happy Holidays

Xhtml/CSS No Comments »

Holidays are here, a moment of joy and good time for all of us in the middle of friends and family. I wish Happy Holidays and Merry Christmas to everyone and if this will be the last post of this year, I also say: Happy New Year!

Valid XHTML 1.0 Strict pages with flash on them

JavaScript, Xhtml/CSS 1 Comment »

Everyone knows there is a problem in having a valid XHTML 1.0 strict page when you want to use some flash on it. In another post I described how this can be done but unfortunately that thing wasn't complying with the XHTML 1.0 strict instead was fine for the pages validating using the Transitional Standard of W3C XHTML specifications.
Now I came back on this subject with a solution that fix the "Strict" problem, for this I appealed to a little help from Javascript using the getElemementById method.
To insert a flash code in a web page according to the adobe specification you have to use a code almost similar with this one:

  1. <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=",0,29,0" width="590" height="400">
  2.     <param name="movie" value="swf/flash.swf">
  3.     <param name="quality" value="high">
  4.     <embed src="swf/flash.swf" quality="high" pluginspage="" type="application/x-shockwave-flash" width="590" height="400"></embed>
  5.   </object>

Above code will insert an flash movie with the width of 590 and the height of 400, the flash movie is called flash.swf and it is situated in the swf directory. This code will cause some errors (I will not tell you here which) and the page fails to validate.
My method is to remove all the flash code from the page and to insert it using a small external javascript file.
The javascript file we will call it flash.js and place it in the /js directory inside the site root and should have the following content:

  1. function flash(){
  2. document.getElementById('flash').innerHTML = "<object width=\"590\" height=\"400\" codebase=\",0,29,0\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"><param value=\"swf/flash.swf\" name=\"movie\"/><param value=\"high\" name=\"quality\"/><embed width=\"590\" height=\"400\" type=\"application/x-shockwave-flash\" pluginspage=\"\" quality=\"high\" src=\"swf/flash.swf\"/></object>";
  3. }

Be careful to write all this code on a single line because it is a string and a string in javascript can't be stretched on multiple lines. As you see we are using the document.getElementById('flash').innerHTML method to write some content on a div with the id flash. The page should have the following code:

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "">
  3. <html>
  4. <head>
  5. <title>Insert valid Flash in XHML 1.0 Strict</title>
  6. <script type="text/javascript" src="js/flash.js">   
  7. </script>
  8. <style type="text/css">
  9. #flash {
  10. width: 590px;
  11. height: 400px;
  12. background-color: #777;
  13. }
  14. </style>
  15. </head>
  16. <body onload="flash()">
  17. <h1>Insert flash animation using javascript</h1>
  18. <div id="flash"></div>
  19. </body>
  20. </html>

The result will display a valid page with a flash on it. As you see we include the javascript external file and we load the flash() function from it using the body event onload. The flash code is not displayed and everything we have at View source is the empty div.
That's all.

Very common DTDs

Xhtml/CSS 1 Comment »

Despite writing a good valid code and a valid CSS for your webpage, if you don’t specify the right DOCTYPE or you won’t specify it at all meaning that your page will be rendered in quirks mode and it can behave strange displaying visual errors that can be very unpredictable damaging your layout.
Bellow is a list with the most common DTDs I in my developing process respectively for HTML 4.01, XHTML 1.0 Transitional, XHTML 1.0 Strict.

  2. "">
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  5. "">
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  8. "">


XHTML 1.o Specifications

Xhtml/CSS No Comments »

For those who are working with the XHTML 1.0 here are the full specification list of this markup language, with the W3C recommendations from January 2000 revised in August 2002. You can find content like :
Normative Definition of XHTML 1.0
Differences with HTML 4
Compatibility Issues
Element Prohibitions
HTML Compatibility Guidelines
and other useful things.

Great resources for CSS

Xhtml/CSS No Comments » it is a great resource for CSS, it is divided in areas like browsers testing, editors of css, css concepts, example of layouts, switching (about rendering mode), hacks, sizing text, sizing images, and a lot more of tricks very useful for a professional web developer.

Using float model in CSS

Xhtml/CSS No Comments »

Here you can find a good article about the power of float model in CSS construction. This property it's a very important in solving non-tables layouts.

Valid XHTML when inserting flash code

Xhtml/CSS 3 Comments »

Even if flash is very used on web pages a lot of web developers still don't know a correct way to insert a .swf movie into a website. There are different ways for different browsers, the <object> element with it's attributes is used for Internet Explorer needs, instead other browsers (like Firefox for example) recognize only the <embed> element. The problem is that this element isn't listed in HTML or XHTML specifications, soo the code is not valid.
To solve this problem I'm using this code which is working in both most important browsers Internet Explorer and Firefox:

  1. <object data="path_to_flash" type="application/x-shockwave-flash" width="557" height="127">
  2. <param name="MOVIE" value="path_to_flash">
  3. </param></object>

Using this method, now you can easily insert flash content in your site without concerning that the final source will not be valid, this works fine for HTML and even XHTML 1.0 Strict .

Good way to replace table based menus

Xhtml/CSS No Comments »

A heavy-table menu navigation can be replaced successfully by an unordered list formatted from css. With a little help of Javascript nested unordered lists can be quickly converted into drop-down menus. “Son of Suckerfish” (SoS) menu script, that you can find it here is developed by Patrick Griffiths and Dan Webb. This is a very good example how good can JavaScript and CSS work togheter.

Theme designed by N.Design Studio
Entries RSS Comments RSS Log in