Client Feedback Matters

Read More

How to put text into a Transparent Box using CSS

16th August, 2010

Step one of this tidy tutorial is creating a div element (class=”background”) with a fixed height and width, a background image, and a border.

div.background
{
width:730px;
height:400px;
background:url(bg.jpg) repeat;
border:5px solid #CCC;
}

Then we create a smaller div (class=”transbox”) inside the first.

div.transbox
{
width:620px;
height:200px;
margin:30px 50px;
background-color:#000;
border:1px solid black;

In addition we need to make this div transparent.

div.transbox
{
width:620px;
height:200px;
margin:30px 50px;
background-color:#000;
border:1px solid black;
/* for IE */
filter:alpha(opacity=60);
/* CSS3 standard */
opacity:0.6;
}

Inside the transparent div, we add some text inside a p element.

div.transbox p
{
margin:30px 40px;
font-weight:bold;
color:#fff;
}

So your page should look something like:

<html>
<head>
<style type=”text/css”>
div.background
{
width:730px;
height:400px;
background:url(bg.jpg) repeat;
border:5px solid #CCC;
}
div.transbox
{
width:620px;
height:200px;
margin:30px 50px;
background-color:#000;
border:1px solid black;
/* for IE */
filter:alpha(opacity=60);
/* CSS3 standard */
opacity:0.6;
}
div.transbox p
{
margin:30px 40px;
font-weight:bold;
color:#fff;
}
</style>
</head>
<body>
<div>
<div>
<p>Tidy text in here…
</div>
</div>
</body>
</html>

Download sample

Web Design Posts

17th January, 2026

Redesign vs Refresh

13th December, 2025

Festive Colour Palette

9th November, 2025

Client Feedback Matters

Recent Posts

7th February, 2026

What is an AI citation?

10th January, 2026

SEO Predictions 2026

5th January, 2026

Happy New Year!