Archive for the ‘ HTML ’ Category

Problem with href attribute in named anchors

Wednesday, October 30th, 2013 By Nik

Sometimes even the simplest things in life that we always took for granted seems to give us a kick on our backside. That is when we get to learn little lessons of life. The simplest piece of code that always worked like charm, fails to work, Today was just that day. I had an issue with a named anchor which I had defined to add a Jquery Smooth Scroll. The scroll to an anchor just failed to work … thankfully it was a very simple fix.

The code that I had (when the named anchor did not work) 
<a href="" id=”a_rate_this”></a> 
Got fixed when , I replaced the above with  
<a href=”javascript:void(0);” id=”a_rate_this”></a>
Or even just remove the href attribute as below
<a id=”a_rate_this”></a>
yeah! but in this case you will loose the default pointer cursor 
of the anchor tag and it will change to cursor of type text. 
You could solve this issue with a css fix, 
i.e. by adding cursor:pointer to the anchor tag.

get ExpressingIT News by Email Subscribe to ExpressingIT by Email or  Follow Me on Twitter

Aligning radio button with text

Thursday, March 4th, 2010 By Nikhil

Since the radio button and the text are inline, so the text will align itself to the bottom of the radio button, The the text will appear to be slightly under the radio button.
If you want these to align to the top, you’ll have to place the radio and the text into separate containers like divs or spans ( as appropriate) and they will take care of the alignment. It would be easier to use table cells too, of your design brief permits it.

This won’t look the same in every browser, as every browser displays radios slightly differently, so there’s always going to be size issues no matter what you do.

get ExpressingIT News by Email Subscribe to ExpressingIT by Email or  Follow Me on Twitter

What will HTML5 bring?

Friday, January 8th, 2010 By Nikhil

HTML5 is still a draft. As I write, Work on HTML 5, which commenced in 2004, is still being given shape by a joint effort between the W3C HTML WG and the WHATWG.   The word is that the next gen HTML will have  enhancements and  features, which would new structure and semantics , form controls, APIs, multimedia tags etc..

In simple English … what would it mean to  us UI developers …

  • There will addition of some structural tags  viz.  <article>, <section>, <header>, <aside>, and <nav>, which would replace the majority of <div>s used on a web page, making your pages a bit more semantic, but more importantly, easier to read.
    Hey! Just imagine the effort saved in finding that one missing close DIV tag.

Instead of

  <div id="header">...</div>
  <div id="nav">...</div>
  <div class="article">
    <div class="section">
  <div id="aside">...</div>
  <div id="footer">...</div>
  • With the advent of  audio and video content like YouTube, the use of embedded multimedia on the webpage has increaded by fold. Taking this into account , Now the plan is to add native support for embedding video and audio into the browser itself,  hence allow users to play, pause, stop, seek, and adjust volume using the builtin DOM APIs for scripts to control the playback.


<video poster="poster.jpg">
    <source src="video.3gp" type="video/3gpp"
        <source src="video.mp4" type="video/mp4">
  <source src="music.oga" type="audio/ogg">
  <source src="music.mp3" type="audio/mpeg">
  • Better-defined semantic roles for existing elements  for eg. <strong> and <em> might now actually have different  meanings i.e.  they will behave differently.

There are many more changes/upgrades to the newer version … Will keep updating this post as I come accross any interesting useful ones …. Watch this space

This document may not provide accurate information as the HTML 5 specification is still actively in development. When in doubt, always check the HTML 5 specification here.

get ExpressingIT News by Email Subscribe to ExpressingIT by Email or  Follow Me on Twitter


Sunday, October 18th, 2009 By Nikhil
  • The Document Type Declaration needs to be present at the beginning of a document that uses the HTML syntax. It may optionally be used within the XHTML syntax, but it is not required. The XHTML document does not need to include the DOCTYPE because XHTML documents that are delivered correctly using an XML MIME type and are processed as XML by browsers, are always rendered in no quirks mode.
  • In XHTML, tag names are case sensitive and are usually defined to be written in lowercase. In HTML, however, tag names are case insensitive and may be written in all uppercase or mixed case, although the most common convention is to stick with lowercase. The case of the start and end tags do not have to be the same, but being consistent does make the code look cleaner.


  • Backwards compatible with existing browsers
  • Authors are already familiar with the syntax
  • The lenient and forgiving syntax means there will be no user-hostile “Yellow Screen of Death” if a mistake accidentally slips through
  • Convenient shorthand syntax, e.g. authors can omit some tags and attribute values


  • Strict XML syntax encourages authors to write well-formed markup, which some authors may find easier to maintain
  • Integrates directly with other XML vocabularies, such as SVG and MathML
  • Allows the use of XML Processing, which some authors use as part of their editing and/or publishing processes

get ExpressingIT News by Email Subscribe to ExpressingIT by Email or  Follow Me on Twitter

IS disabled=”true” and disabled=”false” the same?

Tuesday, March 24th, 2009 By Nikhil

This ones old school , but as usual it is my memory supplement …
So is disabled=”true” and disabled=”false” same?Yes
… Don’t believe, well! thats the way it is … here is some quick explanation…
“disabled” is an attribute of any form element/field and hence can accept any value by its nature.

As long as this attribute is present, the element will be disabled regardless of its value. for eg.
<input type=”text” value=”This is disabled” disabled>
<input type=”text” value=”This is disabled” disabled=”disabled”>
<input type=”text” value=”This is disabled” disabled=”true”>
<input type=”text” value=”This is disabled” disabled=”false”>

All of the above will make the this form field “DISABLED”.

Simply not providing the attribute “DISABLED” keeps the Field “ABLED” … like below

<input type=”text” value=”This is not disabled” />

Remember “Any value (or no value at all) of the disabled attribute, the browser will render it disabled” . To keep things clear in our minds W3C recommends that we use disabled=”disabled” in these situations.

This is difference though when we use this attribute in javascript …

document.form.element.disabled = true; //the element will be disabled
document.form.element.disabled = false; //the element will be enabled

The above arguments are also true for these attributes and elements :

  • checked (radio button and checkbox)
  • selected (option)
  • nowrap (td)

get ExpressingIT News by Email Subscribe to ExpressingIT by Email or  Follow Me on Twitter

Mis-behaving IE8 : CSS Layout breakages (Targeting a browser version using Meta Tags in IE8)

Wednesday, December 17th, 2008 By Nikhil

If you are css person, you would know the pain in getting your layouts working cross-browser. IE8 is yet another spanner in the works for us developers. Anywaz! if you hit upon this issue, Like I did yesterday, where your perfectly working CSS in IE7 (and earlier) and  Firefox  has suddenly started throwing tantrums in IE8 , TRY This … It nicely seemed to fix my problems for the moment ….

Using Meta declaration, we can specify the rendering engine we would like IE8 to use. So to force IE8 to render as IE7 … Insert the following Meta Tag into the head of your document:-

<meta http-equiv=”X-UA-Compatible” content=”IE=7″ />

By default IE Meta would be:-

<meta http-equiv=”X-UA-Compatible” content=”IE=8″ />
which would make IE8 render the page using the new standards mode.

If required, this syntax could be used to accomodate for other browsers as below:

<meta http-equiv=”X-UA-Compatible” content=”IE=8;FF=3;OtherUA=4″ />


IF you are yet unfamiliar with the sort of animal called “Doctype” … here is some quick read
Setting the DOCTYPE in XSL

For a more in depth understanding about DOCTYPES , try visiting these links…
A List Apart : Fix Your Site With the Right DOCTYPE!
A List Apart : Beyond DOCTYPE: Web Standards, Forward Compatibility, and IE8

Note: Though many of us HTML/CSS people have been neglecting the importance of DOCTYPE decleration in our documents , Setting the right DOCTYPE , is usually the answer to most cross browser issues.

get ExpressingIT News by Email Subscribe to ExpressingIT by Email or  Follow Me on Twitter

Disappearing HTML/DIV elements in Internet Explorer [IE]

Saturday, October 4th, 2008 By Nikhil

As usual, one of the many some strange problems with IE and this one must ranks in TOP 10 of IE Quirks.

PROBLEM STATEMENT (This was my problem, maybe you have similar misbehaviors):
I have many DIV’s in the page with class “sectionhead” , which is nothing but title of a section on the page. So I have some style looking like this

.sectionhead{font-size:18px; background:#cfcfcf; padding:5px;}

The div is a light grey bar with some black text. What happens in IE is some of these section headers are displayed ok, but some are invisible, UNTIL, you scroll the page or click something on the page etc. Sometime they tend to disappear when you click the ‘alt’ key when you page down or scroll with the scroll bar. They sometimes seem to reappear when you reload (f5) the page. I short a perfectly simple DIV with some simple style behaves BAD.
What could cause such an erratic behavior? Well! Frankly, NO IDEA!!!

Again don’t ask me why, but in many instances this problem tends to vanish when you add position:relative to the mis behaving elements style, like this

.sectionhead{font-size:18px; background:#cfcfcf; padding:5px; position:relative }

Weird but what to say? God Bless me from IE!


get ExpressingIT News by Email Subscribe to ExpressingIT by Email or  Follow Me on Twitter

Simple, Lightweight, Cross Browser Lightbox for your webpage

Friday, October 3rd, 2008 By Nikhil

Not that there are only a few LIGHTBOX’s that you can find when you google. The issue with most of the lightboxes that I found was that they all seemed to use one or the other heavy weight JAVASCRIPT frameworks like JQUERY, PROTOTYPE, MOOTOOLS and the likes. They are all cool and swanky looking. But If your requirement is “BUT I WANT A SIMPLE AND LIGHTWEIGHT LIGHTBOX SCRIPT FOR MY SITE”, then here it is;

Some nice features of this lightbox

  1. Very light
    a. 4kb of Scripts when packed (8 kb unpacked)
    b. 2 kb of CSS
    c. Few lines of HTML for the lightbox container
  2. Simple to understand and implement
  3. Can have multiple Lightboxes on the same page.
  4. The same lightbox container is used to show, different content (which is separately included as hidden divisions in the page), depending on the link/option that is clicked.
  5. Automatically centers itself, taking into consideration all factors such as, Window height and width (screen resolution), page scroll amount and the height of the contents of the lightbox
  6. Tested in IE 7 & FF

View Demo |
Download Lightbox Source Zip (Downloaded 2347 times)

Using the Lightbox[Files in the zip file]

jo.js , jo_pack.js[packed version] :- a simple set of JAVASCRIPT OBJECTS [JO], which contains element, window and document positioning scripts. You can open JO.JS if you wish to get your hands dirty with some Advanced Javascripting, creating abstract functions, extending element properties and such. If you not too much in Javascripting , Leave it alone.

lightbox.js, lightbox_pack.js[packed version]:- Contain light box manager scripts. If you are page designer , also responsible with implementing the lightbox on the page, you need to understand the LightBoxManager . LightBoxManager basically contains just two functions showLightBox and closeLightBox.

lightbox.css :- If you know CSS , you can play around with lightbox.css to customize the look-n-feel lightbox.css

index.html: Sample implementation of the lightbox with two different content

lb_underlay_bkg.png :- This is light/simi transparent image that is used the background for the lightbox underlay [Underlay is the layer below the lighbox, which prevents the user from clicking any other entity on the page, while the lightbox is open]. You can use any image or even a solid color for this purpose, depending upon the page design and the requirement.

icon_lb_close.gif : – The image for close lightbox handle on the top right of the light box. Can use any image as per design

View Demo |
Download Lightbox Source Zip (Downloaded 2347 times)

Please let us have your comments and feedback …

get ExpressingIT News by Email Subscribe to ExpressingIT by Email or  Follow Me on Twitter

Fixed(That remains static on window scroll) Page Blocks using CSS Only

Thursday, September 4th, 2008 By Nikhil

This post might be a good example for the phrase “Teaching grandma to suck eggs” … Cause this is just BASIC CSS Stuff. But for those , like the oblivious me, this might be a blessing in disguise. I always thought (I could loose my job for saying this), it was ONLY possible to keep some part of the HTML page content STATIC (meaning, its position remains AS IS on Window Scroll), using some smart scripts, Doing all those scientific calculations to find dynamic position, trapping Window.scroll events and setting timeouts etc.

Never thought it could as simple as this …. Here in the CSS/HTML below , I have four static blocks, one fixed to each extrimities of the page, TOP, RIGHT, BOTTOM and LEFT … needless to say … you can choose any one or more if need be …

.static{display: block; z-index: 10; color: #ffffff; overflow-x: hidden; overflow-y: hidden; position: ixed;
#contents{ margin: 100px 150px 0px 160px; border:1px solid #e6e6e6 }

#wrap-t { top: 0px; background:#33CC66;  width: 100%; height: 55px;}

#wrap-l { top: 80px; background:#FF9966; height:300px; width:150px; border:2px solid #e6e6e6;}

#wrap-b { bottom: 0px; background:#3333CC;  width: 100%; height: 55px;}

#wrap-r { top: 80px; background:#6666FF; height:300px; width:140px; border:2px solid #e6e6e6; right:0; }

<div id=”contents”> You main page contents </div>
<div id=”wrap-b” class=”static”>
  Static Content on Page  bottom
<div id=”wrap-t” class=”static”>
  Static Content on Page  Top

<div id=”wrap-l” class=”static”>
  Static Content on Page  left
<div id=”wrap-r” class=”static”>
  Static Content on Page  right

View a wroking sample here

get ExpressingIT News by Email Subscribe to ExpressingIT by Email or  Follow Me on Twitter

CSS hack: Javascript, CSS, HTML for Firefox only

Tuesday, September 2nd, 2008 By Nikhil

Many a times we feel the need to write browser specfic hacks (though it is not a good practice, we UI developers have to resort to such evils until the great Browsers Wars comes to a truce). Earlier , I had mentioned in this article For your IEs Only, how to write a CSS snippet that would be visible to IE browsers < IE7 only.

Yesterday, I had a case, where I wanted to write some FireFox specific CSS snippets. Well! I am not sure if there is a CSS code for this but there is a HTML. THERE IS A CATCH THOUGH, this piece of HTML doesnot pass HTML validation. But , anywaz! If you are stuck badly or as such, have no-regards for validation (sometime we have to be cruel), you could use the following to declare a link to a FF only stylesheet or even just code the CSS within this block. The code is

<comment> Put your FireFox only HTML/CSS/Scripts here </comment>

             /* Styles for FF only  */
             fieldset{border:1px solid #dddddd;}

I”m happy for the moment …

get ExpressingIT News by Email Subscribe to ExpressingIT by Email or  Follow Me on Twitter

 Subscribe to ExpressingIT RSS
get ExpressingIT News by Email Subscribe to ExpressingIT by Email
 Follow Me on Twitter