
How do I add spacing to images in my RSS feed?I'm pulling out my hair! I want to include images in my blog entries and have those images show up in the RSS feed too, but either I end up with no image showing up at all, or I end up with the text abutting the image, which looks terrible. What's the best practice with this, Dave? I read almost 200 different RSS feeds every day with NewsGator Online and know exactly what you mean. Even the best, biggest sites have similar problems because either they don't remember that RSS feeds are read in other programs or because they don't know enough CSS or HTML to tweak the layout. For example, here's a nice example of how the otherwise splendid GigaOm blog has spacing problems with its RSS feed: ![]() Clearly it would be more attractive if there were just a few additional pixels of blank space around the edge of the image, and that's easily accomplished either in HTML or, better, using Cascading Style Sheets. You include an image in your blog posting through a tag like this: <img src="some url" />
I strongly -- strongly -- recommend that you always specify alt text too, ideally describing exactly what the image is about. This helps both with people who can't or don't want to load images (think "ADA Compliant") and it also helps with search engine ranking too. My image above, for example, includes the following: alt="GigaOm RSS Image Spacing Problems". If you want to have the text wrap around the graphic, you're probably also adding align="right" or align="left" depending on your desired layout and appearance. Add these two in, and your image inclusion's a bit more complex: <img src="URL" alt="alt text" align="right" />
That's a typical way to get a graphic on the page and, if it's in the part of your blog entry that's included in your RSS feed, in the RSS feed too. But what if you want to add a bit of spacing? There are two ways to add spacing to an image. Within the world of HTML, you can add horizontal and/or vertical spacing with the hspace and vspace attributes, respectively. The unit of measure is pixels and the value is applied to both sides, so specifying hspace="8" will add 8 pixels of blank space on both the left and right of the image. The more sophisticated solution is to use CSS, however, because you have greater control. If you want to have that 8 pixels of space around all four sides, for example, use margin:8px;, but if you really only want the right and bottom edges to have the extra spacing, you can do that with margin-right: 8px; margin-bottom: 8px;. Note carefully my use of colons and semicolons. Dropping CSS into an HTML tag is done with the style attribute, so here's our completed example image that includes an additional 8 pixels of space around it: <img src="URL" alt="alt text" align="right" style="margin:8px;" />
You can do that, right? :-) What about missing images? the other problem, and one that I see in RSS feeds with alarming frequency, is that the image is completely missing when the feed is viewed. Sometimes this is just a transient server problem, but mostly it's due to a lack of specifying a fully qualified URL. Your blog articles can include partial URLs like "/images/neatpic33.jpg" without an issue, they show up fine when people read your blog by visiting your site, but without a domain name specified, the RSS readers just don't know what to do and can't deliver the image where you want it. The fix is easy: Always specify the http:// material in any blog image reference. On the image inclusion above, just by way of example, here's the actual HTML code I am using: <img src="http://www.askdavetaylor.com/0-blog-pics/gigaom-rss-image-error.png" alt="GigaOm RSS Image Spacing Problems" />
Rather a long URL, but I'm confident it'll work regardless of how this blog entry is referenced. That's all there is to it. I hope you find this helps you tweak your RSS feed to meet your aesthetic desires!
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon
Categorized:
Blogs and RSS Feeds
(Article 6926)
Tagged: blogging, css, html, photographs, pictures, rss, rss feed Previous: Why am I getting PSA ads on my blog? Next: How many editions of a book have been published? Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader. I am carefully noting your use of colons and semicolons and wanted to point out that there are two semicolons that aught to be colons. One in the "margin-right" style statement and one in the URL portion of "the fix is easy". Posted by: Ben Zvan at October 19, 2006 12:46 PM(sound of me slapping my forehead) Doh! Thanks for the note, Ben. I've fixed it all up. Posted by: Dave Taylor at October 19, 2006 1:19 PMre. fully qualified URL for img src I have a lot to say, but ...
I do have a comment, now that you mention it!
|
![]()
Search
Find just the answers you seek from among our 2300+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Industry News and Trade Shows Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Book Links
|