css code snippets to spice up your lenses
Ranked #2,797 in Squidoo Community, #235,742 overall | Donates to Squidoo Charity Fund
what is css?
snippets?
That's geek-speak for little pieces of code you can re-use.
Don't copy and paste, because the text you see is not code.
You need to type it.
Watch this video about styling pages with css
tutorial: styling images
using CSS
image code snippet
This code:
[< img src="http://static.squidoo.com/resize/squidoo_images/250/draft_lens4154672_1240201438snippets.jpg" alt="logo for this lens" />]
gives this:
image with a caption
inside your text
[ < img src="http://static.squidoo.com/resize/squidoo_images/250/draft_lens4139982module28273882photo_1240105687purple_medallion.jpg" alt="purple medallion quilt" />] [<br />] [<em>Caption here</em>]
Declarations mean:
[ < img src="http://static.squidoo.com/resize/squidoo_images/250/draft_lens4139982module28273882photo_1240105687purple_medallion.jpg" alt="purple medallion quilt" />] = where Squidoo can find the image
[<br />] = put a line break here so that the caption is under the image
[<em>Caption here</em>] - the caption in italics. It could be normal or bold also.
Gives:

Caption here
more ways to style images
double border
CODE for style declaration:
[ style="border:double #ccc 10px; padding:10px; " ]
CODE below
[< img src="http://static.squidoo.com/resize/squidoo_images/250/draft_lens4154672_1240201438snippets.jpg" alt="logo for this lens" style="border:double #ccc 10px; padding:10px; " />]
gives:
highlight a special picture
to give it a frame
or like this
with a coloured picture frame for extra special emphasis
CODE:
[< style="border: outset #0482CE 30px; padding:30px; " >]
Good reads about CSS Stuff
on Amazon
tutorial: background images
using css
add an image
to the background
CODE for background:
[< style="background: url(http://squidoo.com/XXX.jpg); " >]
This paragraph has a background image and an inline image.
The Ulysses is in the background, while the two little butterflies are inside the paragraph.

There are three problems here: the text is unreadable, the image is repeated over and over and over, and you can see the background of the two little butterflies.
First we need to tell the image not to repeat, by adding 'no-repeat' to our background property. I'll also give a 3px space at the top and the left so it doesn't bump into the border.
New CODE for background:
[< style="background: url(http://squidoo.com/XXX.jpg) no-repeat 3px 3px;" > ]
This paragraph has a background image and an inline image.
The Ulysses is in the background, while the two little butterflies are inside the paragraph.

Still some problems...
better styling of images
in the background
New CODE for aligning text right:
[ < text-align:right; > ]
This paragraph has a background image and an inline image.
The Ulysses is in the background, while the two little butterflies are inside the paragraph.

Right aligned text is not easy to read because we read from left to right and our eye needs a guide along the left for where the lines begin and end.
Not right yet...
much better styling of images
in the background
New CODE plus line-height of 2 for space between the lines:
[ < style="border:solid #ccc 10px; padding:10px; padding-left:120px; line-height:2;" > ]
This paragraph has a background image and an inline image.
The Ulysses is in the background, while the two little butterflies are inside the paragraph.

Let's float the image to the right.
New CODE for image:
[ < style="float:right;" > ]
This paragraph has a background image and an inline image.
The Ulysses is in the background, while the two little butterflies are inside the paragraph.

The little butterflies are flying outside the frame, so we need to add some negative top margin. This will bring it up so it is inside.
New CODE:
[< style="float:right; margin-top:-42px;" > ]
This paragraph has a background image and an inline image.
The Ulysses is in the background, while the two little butterflies are inside the paragraph.

Now that's the way I like it!
tutorial: images as borders
for your text modules
the box model
for css
I'll put a border around the 'box' that the paragraph is enclosed by, so you can see all the changes we make are only happening to the paragraph.
These (usually) invisible boxes are how CSS code works. It's called the box model.
Here are two cute butterflies behind the paragraph.
The words are just in there to have some text so you can see what happens in a real paragraph in a text module.
The basics of this lesson are the same code as in the tutorial with both large and small butterfly images, above.
add the butterflies to the background
[background url(image location)]
Here are two cute butterflies behind the paragraph.
The words are just in there to have some text so you can see what happens in a real paragraph in a text module.
That's not it! We can't read the writing.
tell the image not to repeat
[background url(image location) no-repeat]
Here are two cute butterflies behind the paragraph.
The words are just in there to have some text so you can see what happens in a real paragraph in a text module.
Now we can see the writing a bit better, but not the beginning.
add some left margin
[ margin-left: 60px; ]
Here are two cute butterflies behind the paragraph.
The words are just in there to have some text so you can see what happens in a real paragraph in a text module.
Whoops! Not margin, then.
add some padding
[ padding-left:60px; ]
Here are two cute butterflies behind the paragraph.
The words are just in there to have some text so you can see what happens in a real paragraph in a text module.
That's better! Not margin, padding.
repeat the image along the top
across the x-axis (remember graphs at school?)
Here are two cute butterflies behind the paragraph.
They are just in there to have some text so you can see what happens in a real paragraph in a text module.
Uh oh, that's not what we wanted!
We need to add some top padding.
Here are two cute butterflies behind the paragraph.
The words are just in there to have some text so you can see what happens in a real paragraph in a text module.
[ padding-top:50px; ]
repeat the image along the bottom
[repeat-x bottom left; ] [ padding-top:60px;]
Here are two cute butterflies behind the paragraph.
The words are just in there to have some text so you can see what happens in a real paragraph in a text module.
We should change the padding from top to bottom.
Here are two cute butterflies behind the paragraph.
The words are just in there to have some text so you can see what happens in a real paragraph in a text module.
[ padding-bottom:60px; ]
repeat the image down the left side
on the y-axis
Here are two cute butterflies behind the paragraph.
The words are just in there to have some text so you can see what happens in a real paragraph in a text module.
[ padding-left:60px; ] [ repeat-y; ]
tell the image to go down the right side
[ background url(image location) repeat-y right top; ]
Here are two cute butterflies behind the paragraph.
The words are just in there to have some text so you can see what happens in a real paragraph in a text module.
We should change the padding from left to right.
Here are two cute butterflies behind the paragraph.
The words are just in there to have some text so you can see what happens in a real paragraph in a text module.
[ padding-right:60px; ]
That's better.
Video about using background images in css
here it is without the border
around the paragraph
Here are two cute butterflies behind the paragraph.
The words are just in there to have some text so you can see what happens in a real paragraph in a text module.
[ border:none; ]
same code, different image
[ background url( NEW image location) repeat-x bottom left; ]
Here are two cute butterflies behind the paragraph.
The words are just in there to have some text so you can see what happens in a real paragraph in a text module.
Have fun using these techniques in your own lenses.
mini tutorial: add borders to text
border
around special items
[ < p style=" float:left; padding:20px; margin:6px; border: solid 3px #6B8E23; text-align:left;" > Title, body text </> ]
Declarations mean:
float:left; = box stays on the left of the page
padding:20px; = 20px space inside the border
margin:6px; = 6px of space autside the border
border:
solid = style of the border, such as one line, or dotted or dashed,
3px = thickness of border
#6B8E23 = colour for border;
text-align:left; = text stays at the left inside the box
Gives:
Title of item here
Text text text text text text Text text text text text text Text text text text text text
Text text text text text text Text text text text text text Text text text text text text
Text text text text text text Text text text text text text Text text text text text text
Simple image borders using css
mini tutorial: change the look of text
italics, bold
for emphasis
[<em> text here </em>] and [< strong > text here </ strong >]
Declarations mean:
em = italic
strong = bold
Gives:
text here and text here
CSS 2.0 says 'bold' and 'italics' are not to be used here, use em and strong instead.
Changing how the text appears for emphasis, etcetera, using css
em dashes
to separate stuff
[—]
This code:
[one word space "—" space another word]
Gives:
one word — another word
lenses with CSS tips
code and hints from other Lensmasters
tutorial: white space
or line-height
Use the link to my newest css lens below to see an in-depth tutorial about this essential CSS property.
tutorial: using the line-height property
in your lenses
Some of my web design lenses
Enjoy!
About Me
and web design
did you learn much?
want more?
Drop me a line...
-
-
Frank2009
Nov 2, 2011 @ 10:00 am | delete
- Some great tips there... thank you....
-
-
-
JanTUB
Nov 5, 2011 @ 6:47 pm | delete
- Glad to help
-
-
-
BuckHawk
Sep 23, 2010 @ 8:07 am | delete
- Thanks, Jan. This is exactly what I need. Sent it to my bookmarked lenses so I can get this all the time! Great tutorial!
-
-
-
JanTUB
Sep 24, 2010 @ 2:38 am | delete
- You are so welcome, and any time I can help. My other hat (apart from quiltmaker) is web designer, you know.
-
-
-
lemonsqueezy
Sep 23, 2010 @ 7:31 am | delete
- I "like" this. Great information! Can't wait to try some of this on my lenses.
-
- Load More
learn from this lens?
tell someone else so they can learn too
This module only appears with actual data when viewed on a live lens. The favorite and lensroll options will appear on a live lens if the viewer is a member of Squidoo and logged in.
by JanTUB
I have been quilting for more than a quarter of a century. (Sounds much longer than 25 years.) That's me in my studio in 2006.
Quilt tutor, patchwork...
more »
- 132 featured lenses
- Winner of 20 trophies!
- Top lens » What can you do with a 'walking' foot?
Explore related pages
- Font fun for lovely lenses Font fun for lovely lenses
- More white space: more 'readable' lenses More white space: more 'readable' lenses
- What are cascading style sheets (css)? What are cascading style sheets (css)?
- My Squidoo How-To lenses My Squidoo How-To lenses
- Tools For Squidoo Lensmasters ヅ Tools For Squidoo Lensmasters ヅ
- Squidoo Blogs Value Squidoo Blogs Value