
I tried to factorize the code to make it simple, readable, compact and easily usable. We’ll use that wrapping div as a container for absolute positioning. Putting the image in as a background image of the wrapping div would be easier, but in this scenario I see the images as content, and thus belongs in the HTML.
Note: I'm not talking here about text over a background image, which is standard in HTML, but text over an image element (the img tag). In CodePen, whatever you write in the HTML editor is what goes within the tags in a basic HTML5 template.Move the text to the correct place on the picture, for example in Gimp use.

Adjust the font, font size, and attributes like Bold, etc. Add a new text layer, in Gimp the Text Tool (shortcut 'T') will automatically add the text as a new layer. In HTML, it means that it is out of the flow, because it has to be positioned over another element, which is not possible with the default behaviour. A simple way to make the overlay is to: Open a copy of the main image in, say, Gimp. You can find different ways to do it on the internet, but I wanted to synthesize everything I found to extract a minimal and above all clean solution.įor me, an overlay is just a layer put on top of another. Simply integrate the HTML code on a page and the CSS code into your stylesheet. Use the Container element to create a background, and then.

#Overlay text on image html how to#
The code provided in this article may apply to any website. How to overlay text, buttons, and other elements on an image or video, using the Container element. Indeed, who has never wanted to quickly position a text over an image? Here is a very simple tutorial to design image overlays in HTML and CSS only.

The idea is just to overlay some text over an image.
