
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create an image with a transparent background text using CSS?
Following is the code to create an image with transparent background text using CSS −
Example
<!DOCTYPE html> <html> <head> <meta name="viewport" imageContent="width=device-width, initial-scale=1"> <style> * { box-sizing: border-box; } body { font-family: Arial; font-size: 17px; } .imageContainer { display: inline-block; position: relative; } .imageContainer .imageContent { position: absolute; bottom: 0; background: rgba(29, 6, 43, 0.5); /* Black background with 0.5 opacity */ color: #f1f1f1; width: 100%; padding: 20px; } </style> </head> <body> <h2>Image with Transparent Text</h2> <div class="imageContainer"> <img src="https://i.picsum.photos/id/59/500/500.jpg"> <div class="imageContent"> <h1>Sceneray</h1> <h3>A beautiful scenary showing fence, barbed wires and grass</h3> </div> </div> </body> </html>
Output
The above code will produce the following output −
- Related Questions & Answers
- Create a transparent image with CSS
- How to create a blurry background image with CSS?
- How to create a full-page background image with CSS?
- How to create a canvas with background image using FabricJS?
- Create a transparent box with CSS
- How to create a semi-transparent background in Canva?
- Setting Background Image using CSS
- How to create an image gallery with CSS
- How to create an avatar image with CSS?
- How to place text blocks over an image using CSS?
- Set the background image of an element with CSS
- Repeat the background image with CSS
- Specify the background image with CSS
- How to set background image in CSS using jQuery?
- How to position text to center on an image with CSS
Advertisements