Background-rgba doesn't work on simple snippet?

Background-rgba doesn't work on simple snippet?



Have tried this for half an hour now and I still don't get why such a simple snippet won't have background-color:




#section3
z-index: 5;
overflow: hidden;
width: 100%;
height: auto;
background-color: rgba(0, 0, 0, 1);


h3
position: relative;
text-align: center;
margin-top: 10vh;
font-size: 2em;


<span id="section3">
<h3>Unser Anspruch</h3>
</span>



JSFiddle





Using a h3 inside a span is invalid. A span can only contain other inline elements, but not block one's, as a h3 is. Change your span to e.g. a section and it will work: jsfiddle.net/Qhdaz/2061
– LGSon
Aug 25 at 15:36



h3


span


span


inline


block


h3


span


section




1 Answer
1



span is an inline-block element, hence it cannot be given height


span



Inorder to give it height, u will have to convert it into display:block or display:inline block


display:block


display:inline block



But as @LGSon said, h3 must never be put inside a span element


h3


span



Instead of using span, use a div as div is display:block
by default


span


div


div


display:block




#section3
z-index: 5;
overflow: hidden;
width: 100%;
height: auto;
background-color: rgba(250,0,0,1);


h3

position: relative;
text-align: center;
margin-top:10vh;
font-size: 2em;


<div id="section3">

<h3>Unser Anspruch</h3>
</div>





you should change span to div instead of making the span block
– Temani Afif
Aug 25 at 15:40





@TemaniAfif , updated the answer
– Gautam Naik
Aug 25 at 15:46





I could have sworn I tried this, since this seems so obvious but apparently I didn't haha :) thanks so much, I of course knew about the differences between div and span as inline and block elements, and that span doesn't have a height only seems logic, but I never actually saw it like this. Thank you for solving my problem and teaching me something new haha :) have a great day
– Sir Falk
Aug 25 at 22:35







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế