Line breaks and blank lines
Plain text typed or pasted in a text widget flows in one continuous paragraph. For line breaks you need this:
For blank lines you can use this (you can adjust it by changing the number):
This code can also be used alone in a nameless text widget, as a spacer (to create more distance between other widgets).
In some themes the text shows up too close to the widget borders; you create some space around it this way (you can change the number):
The plain code for a link to any webpage is this:
<a href=”URL HERE”>TEXT HERE</a>
In most cases it’s better to use this:
<a href=”URL HERE” target=”_blank”>TEXT HERE</a>
This way the link opens in a new browser window or tab, so that visitors don’t really leave your blog when clicking on a link.
<a href=”mailto:YOUR EMAIL ADDRESS HERE”>TEXT HERE</a>
The content of several widgets (e.g. Categories, Links or Recent Posts) is unordered lists. The design of each theme presents unordered lists in its own way. If you want a list of items in a text widget to show up the same way, you use the code for unordered lists:
<li>ITEM ONE HERE</li>
<li>ITEM TWO HERE</li>
The code for nested lists (with indented sub-items) is like that:
<li>ITEM ONE HERE
<li>ITEM TWO HERE
This is an example with only two main items and three sub-items to each, but it’s enough for demonstrating the structure of the code.
Items and sub-items can be plain words or phrases, or any kind of allowed html code (e.g. links and/or style formatting).
Text widgets with unordered lists can also be used instead of some of the other widgets (such as the links widget or the categories widget). This can be useful if you don’t like the default appearance of those widgets and want to change it using formatting for style, or if you want your links or your categories in a non-alphabetical order; or if you want to include images. The drawback, of course, is that each time you add a new link or category you’ll have to update the text widget manually.
If you want to limit the length a text widget occupies in the sidebar, you can have its content in a (vertical) scroll box:
The height number is just a suggestion – you can change it (but there’s a downward limit: below 45px there’s no room for the scrollbar). “Padding” is the space between borders and text – you can change that too. If you write an unordered list in a scrollbox, omit the padding altogether: the design of the theme will take care of that.
Or you may need a horizontal scrollbox:
In some themes it will look better if you create a visible border around the box; in that case add this right after the opening quotation mark:
border:solid 1px #999;
The code for a plain image is this:
<img src=”IMAGE URL HERE” alt=”DESCRIPTIVE TEXT HERE” />
For an image that links to a webpage:
<a href=”WEBPAGE URL HERE” target=”_blank”><img src=”IMAGE URL HERE” alt=”DESCRIPTIVE TEXT HERE” /></a>
Of course the image has to be narrow enough to fit in the sidebar (in most themes, sidebars are around 150 to 200 pixels wide). If you’ve got a wider image, you can downsize it to fit – example:
<img style=”width:150px;” src=”IMAGE URL HERE” alt=”DESCRIPTIVE TEXT HERE” />
But it’s better to use properly sized images: gives you faster loading, better quality, and no issues with Internet Explorer.
Also note that it’s better to use images uploaded to your own blog (via Media > Add New). If you use the URL of an image hosted in another site, you get the delay of that site loading as well (plus you run the risk of losing the image if it gets relocated or removed).
In some browsers you get a (blue) border around images. If you don’t want that, add this after “img” (with a space in between):
If you want a simple thin border around the image, you can add this after “img” (with a space before and a spacer after):
style=”border:1px solid #HEX NUMBER HERE;”
If you want a left-aligned image, with text wrapping around it, you need to add this after “img” (with a space before and a space after):
class=”alignleft” style=”margin-right: 8px;”
In some themes this may not work. For all kinds of combinations of image plus text, a more surefire way is coding for tables. (But that’s for a future post…)
If you’re having trouble placing text below an image, an easy alternative is using a second, untitled, text widget. (Note: when you add new widgets, you can rearrange them by dragging them into new positions.)