I have two CSS classes: .Chat
and .ChatHeader
and specific rules for <p />
and <button />
, The button aligns fine with the top of my div but no matter if I write top: 0
or height: 100vh
in my style it won't align the <p>
to the top of its parent ChatHeader
, I also tried <h1>
and others but it seems to only work with the button I don't know why: Here is a simple reproductible example:
.Chat {
height: 100vh;
width: 100vw;
background-color: rgb(255, 255, 255);
border: none;
border-radius: 0;
}
.ChatHeader {
width: 100vw;
height: 65px;
background-color: rgb(0, 0, 0);
display: grid;
grid-template-columns: 300px 100px;
grid-template-rows: 65px;
color: rgb(163, 0, 0);
}
.Chat button {
width: 80px;
height: 35px;
background-color: rgb(149, 35, 35);
border-radius: 30%;
color: white;
font-size: 20px;
font-weight: bold;
text-align: center;
line-height: 20px;
cursor: pointer;
}
.ChatHeader p {
height: 100%;
background: none;
color: inherit;
padding: 0;
font-family: inherit;
width: 300px;
background-color: red;
text-decoration: none;
}
<div class='Chat'>
<div class='ChatHeader'>
<p>
Online users: 5
</p>
<button>
Button
</button>
</div>
</div>
I displayed the background of the <p />
as red to show the problem