I have image at the top of the page, then some text below it. What I need is roughly first line of text to be on image. What is a best way to do it using CSS 2 (I’m targeting old devices)?
<html>
<head>
<title></title>
<style>
p.image {
text-indent: 0;
text-align: center;
}
p.image img {
max-width: 100%;
}
</style>
</head>
<body>
<p class="image"><img src="image.png"/></p>
<h2>Title<br/>
title</h2>
<p>Lorem ipsum.</p>
</body>
</html>
2
Answers
You simply need to give a negative "margin-top" to the h2 tag. But if your image is smaller then it would be in the center so in that case, you can add "text-align: center;" to the h2 tag as well so that the text goes to the center with the image.