Html overlay text on image

How lớn put text over images in HTML. Everytime I enter the below code, the text goes under the image.

Bạn đang xem: Html overlay text on image

That is improper HTML; img is a self-closing tag, as so: Alt text (equivalently, in XHTML: Alt text). – kevinji Aquảng bá 22 "11 at 18:28

You can create a div with the exact same kích cỡ as the image.

Some Text

use the css background-image property lớn show the image


more here

note: this slichtly tampers the semantics of your document. If needed use javascript lớn inject the div in the place of a real image.

You need to use absolutely-positioned CSS over a relatively-positioned img tag. The article Text Blocks Over Image gives a step-by-step example for placing text over an image.

Xem thêm: Những Câu Hỏi Thường Gặp Về Bệnh Vảy Nến Ở Phụ Nữ Có Thai, Những Điều Cần Lưu Ý

Whilst Caspar's solution works perfectly well, I've upvoted this one as it degrades nicely. – Sam Starling Atruyền thông quảng cáo 22 "11 at 18:36

The element is empty — it doesn"t have an kết thúc tag.

If the image is a background image, use CSS. If it is a content image, then mix position: relative on a container, then absolutely position the image and/or text within it.

You can try this...

Text you want to display over the image


.image h2
position: absolute; does the trichồng, but a killer for responsiveness – deanwilliammills May 19 "18 at 12:07

Using absolute as position is not responsive + thiết bị di động friendly. I would suggest using a div with a background-image và then placing text in the div will place text over the image. Depending on your html, you might need khổng lồ use height with vh value

Highly active question. Earn 10 reputation in order lớn answer this question. The reputation requirement helps protect this question from spam & non-answer activity.

Not the answer you're looking for? Browse other questions tagged html or ask your own question.

How lớn make a text on an image selectable when rendered in an html page if I have the text present on that image?
What were the parts of each of the six Seuss books that ceased publication in March 2021 that were problematic?
What are the consequences of mistakingly publishing existing research? more hot questions
Staông xã Overflow Questions Jobs Developer Jobs Directory Salary Calculator Help điện thoại
Products Teams Talent Advertising Enterprise
Company About Press Work Here Legal Privacy Policy Terms of Service Contact Us
Stack Exchange Network Technology Life / Arts Culture / Recreation Science Other
Stachồng Overflow Server Fault Super User Web Applications Ask Ubuntu Webmasters trò chơi Development
TeX - LaTeX Software Engineering Unix & Linux Ask Different (Apple) WordPress Development Geographic Information Systems Electrical Engineering
Android Enthusiasts Information Security Database Administrators Drupal Answers SharePoint User Experience Mathematica
Salesforce ExpressionEngine® Answers Stachồng Overflow em Português Blender Network Engineering Cryptography Code Reviews
Magenkhổng lồ Software Recommendations Signal Processing Emacs Raspberry Pi Stachồng Overflow на русском Code Golf
Stack Overflow en español Ethereum Data Science Arduino Bitcoin Software Quality Assurance & Testing Sound Design
Windows Phone more (28)
Photography Science Fiction & Fantasy Graphic Design Movies & TV Music: Practice & Theory Worldbuilding Video Production
Seasoned Advice (cooking) trang chủ Improvement Personal Finance & Money Academia Law Physical Fitness Gardening & Landscaping
Parenting more (10)
English Language & Usage Skeptics Mi Yodeya (Judaism) Travel Christianity English Language Learners Japanese Language
Chinese Language French Language German Language Biblical Hermeneutics History Spanish Language Islam
Русский язык Russian Language Arqade (gaming) Bicycles Role-playing Games Anime & Manga Puzzling
Motor Vehicle Maintenance & Repair Board & Card Games Bricks Homebrewing Martial Arts The Great Outdoors Poker
Chess Sports more (16)
MathOverflow Mathematics Cross Validated (stats) Theoretical Computer Science Physics Chemistry Biology
Computer Science Philosophy Linguistics Psychology & Neuroscience Computational Science more (10)

Blog Facebook Twitter LinkedIn Instagram

site kiến thiết / biệu tượng công ty © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.3.5.38726