Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

Display Text Over Image Using HTML And CSS

Saturday, Jan 21, 2017

Tags:- HTML CSS


In this tutorial we will show you how to display text over image using HTML and CSS we display the text in bottom you can display the text anywhere over the image.You may also like add text to image using PHP.


See Demo
Text Over Image Using HTML And CSS


To Display Text Over Image It Takes Only One Step:-

  1. Make a HTML file and define markup and styling


Step 1.Make a HTML file and define markup and styling

We make a HTML file and save it with a name text_display.html

<html>
<head>
<style>
body
{
 text-align:center;
 width:100%;
 margin:0 auto;
 padding:0px;
 font-family:helvetica;
 background-color:#81DAF5;
}
#wrapper
{
 text-align:center;
 margin:0 auto;
 padding:0px;
 width:995px;
}
#image_div
{
 width:500px;
 margin-left:245px;
 position:relative;
}
#image_div img
{
 width:100%;
}
#image_div #image_label
{
 margin:0px;
 position:absolute;
 bottom:7px;
}
#image_div #image_label span
{
 background-color: #0B4C5F;
 opacity:0.8;
 font-size:25px;
 padding:7px;
 box-sizing:border-box;
 color:white;
 font-weight:bold;
}
</style>
</head>
<body>
<div id="wrapper">

<div id="image_div">
 <img src="image/image1.jpg">
 <p id="image_label"><span>This Is Text Over Image</span></p>
</div>

</div>
</body>
</html>

In this step we create a div which work as a wrapper for image and text then we use simple markup to display text over image.But remember one thing we use 'span' in 'p' element because we need to display background color only behind the text not on the whole paragraph this is the most important rule to display text over image with background color always use inline element for this purpose.You may also like slide text on image using jQuery.



Thats all, this is how to display text over image using HTML and CSS.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

Are You Starting A New Blog
Do You Want Best Web Hosting?

Try World's Best Web Hosting Provider BlueHost
At Just $3.95/mo

Hurry Up! Limited Time Offer

Yes, I Want To Check Out BlueHost

Check The World's Best SEO And All-In-One Marketing Toolkit
For Digital Marketing Professionals SEMRUSH

Check Out SEMRUSH