Using CSS to Hide Long URLs in Your Comments


Daniel, from Daily Blog Tips, found an interesting plugin called WP-Chunk which can truncate long URLS which may occasionally turn up in comments.

For Example,

A URL like:
http://www.domain.com/test/subfolder/x=123/article=id8A133F52D0FD71AB86256C
would become
http://www.domain.com/test/...86C

If you're interested in truncating these long URLs, and don't mind adding a new plugin to your WordPress installation it looks quite handy.

I did want to share a quick CSS related alternative to anyone who wanted to avoid adding to their WordPress install. As you can see both here and on Daniel's post concerning WP-Chunk, the code box allows for scrolling when a URL is too long to fit in it. This is accomplished by adding a small line of code to your CSS stylesheet. You can do something similar for comments.

Simply find the identifier which represents comments and add "overflow:auto" this instructs the browser to turn any element containing long strings to scroll instead of pass beyond the boundaries. Alternately you can also use "overflow:hidden" like I do in my comment section. This allows the long URL to exist but hides it from displaying on the page.

It's not as good a solution as WP-Chunk but it can certainly work for you.


3 Responses to “Using CSS to Hide Long URLs in Your Comments”

  1. April 25th, 2007 at 3:54 pm

    Interesting one!

    Do you have this enabled on your comments? I would like to see it working, let me test:

    http://www.domain.com/test/subfolder/x=123/article=id8A133F52D0FD71AB86256C

    - Daniel
  2. April 25th, 2007 at 7:17 pm

    In my comment section I use “overflow: hidden” while in my code blocks and blockquotes I use “overflow: auto.”

    You actually have it set on your code blocks as well – it’s not as versatile as WP-Chunk but it will work for anyone looking to keep their plugin count low. What I usually do is moderate comments and when I see long URLs I cut them down into a standard link.

    - WildBil
  3. October 9th, 2007 at 5:45 am

    [...] found a new plugin (which I may use) and a CSS trick at Bill2me dot Com that you can use to shorten long URLs in your comments. You know, the ones that are so long they [...]

    - Blog Drive-Bys for 2007-04-28 - Untwisted Vortex
Leave a Reply