Why do I like overflow:scroll so much?


There are times when you want to incorporate a picture, a large piece of code in a limited web space... ex. a blog post which has a lot of <DIV> tags. Now, to crop or resize the picture may not be the option always. I still see a lot posts where the images are either cropped or line breaks are introduced into the code.

The problem with the line break is that it increases the overhead and time spent on the blogger's part in formatting the post. Apart from that, it also creates chances of typos which would make that code snippet not compile when an end user tries it.

Let's say I have a piece of code which I want to blog about (in Windows Live Writer)...

I use Paste from Visual Studio plugin and really love it. When I paste my code from Visual Studio using the Plugin, here is what I get...

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="System.Drawing" %>
<!DOCTYPE html 'I am making this line even longer' PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ OutputCache Duration="72000" VaryByParam="none"  Location="Any" %>

See how the 4th line overflows! Not good, right? So, what next???

Noooo... please don't split that line.....

Select View -> HTML Code and add the DIV tag as follows around the code.

<div style="overflow: scroll">

Your Code Or Image.

</div>

Here is the output...

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="System.Drawing" %>
<!DOCTYPE html 'I am making this line even longer' PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ OutputCache Duration="72000" VaryByParam="none"  Location="Any" %>

Hope this helps, Wave

Rahul

UPDATE> Going forward I will be posting on www.dotnetscraps.com. It will give me much more flexibility in hosting the code and do some of the other things that I have in my mind for quite some time now.

Skip to main content