Home » , , , , » How To Add Caption Above The Image With HTML And CSS

How To Add Caption Above The Image With HTML And CSS


How to add captions above the images not below. It is possible to do it with HTML and CSS.

How To Add Caption Above The Image With HTML And CSS
How To Add Caption Above The Image With HTML And CSS
It is by default in blogger that when we add caption on images it comes below the image. So today we are going to make some changes. You will be able to add captions above the image, then the below. It will not change the default code of blogger for a caption, but you can do it for any image that you use in your post.


For example, when we add caption on images to blogger post, then it looks like this.

caption below image
Caption below image

As you can see captions are below the image, So the main goal of this post is to move the caption above the image. It has been possible through CSS using before and after elements. So you have to manually add this code.

How to add captions above the image.

Below is the html code. Copy the html code and paste it in the blogger post (html mode). And now change the IMAGEURL with the ORL of your image. Now copy the CSS code and go to blogger template. Then click on edit template and hit ctrl+f. Now search for ]]></b:skin> and paste the CSS code above it and you are done.



HTML Code

<li title="Somewhere near Keswick"> <!--content of 'title' will be used as the caption, if the image is linked you can use the title of the anchor as the caption instead -- <li><a href="large-image.jpg" title="Somewhere near Keswick">-->
<img src="http://4.bp.blogspot.com/-zaOreD5GjRw/UmiFX4cJQLI/AAAAAAAAIjw/SCfLCLKkoNc/s320/kissing-teen-couple-romantic-lovers-girl-boy-sexy.jpg" width="200" height="133" alt="Somewhere near Keswick">
</li>


CSS Code

li:before{ /* if you want the caption to appear above the image use li:before , if you're using the title attribute from a link, then change this to a:after or a:before */
content: attr(title);
display: block; /*places the caption on its own line*/
}

Customization


  1. You can customize this code in many ways.
  2. Type your caption on the place of yellow background text.
  3. Insert your image URL on the place of green background color url.
  4. That's it. You are done.


So it was a magic of CSS. You can do many new and creative things with HTML and CSS like we inserted captions above the image.

Title: How To Add Caption Above The Image With HTML And CSS Author: Rohan Mod
Description : How to add captions above the images not below. It is possible to do it with HTML and CSS.
Like us on Facebook
Follow us on Twitter
Recommend us on Google Plus
Subscribe me on RSS