P and h1 tag how to get them in top of the flex box

When I try to make flex box that has a P tag and a H1 tag the p tag pushed to the bottom of the page I’m interested that the H1 and the text and the p tag will be in the top left corner.
This is my code

Any help in what am I doing wrong will be appreciated.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>

<style>
.flex-rectangle{
  display: flex;
  flex-direction:column;
  /* align-content: flex-start; */
  justify-content: center;
  text-align: center;
  width: 80%;
  height:50%;
  background: #ca0164;
 max-height: 500px;
 vertical-align: text-top;
}   
.flex-item {

  background: blue;
  
 }

.flex-rectangle:before{
  content: "";
  display: block;
  padding-top: 25%;
}
p .flex-rectangle {
  color: green;
 }

 .redtitle {
  color: red;
  background-color: black;
} 


h1.title {color: red;}
 

</style>

</head>
<body>
  
  <div class="row">
      <div class= "flex-rectangle">

          

          <h1 class = "title flex-item">This is my header</h1>
          
          
       
          <p  class = "flex-item">This my p tag</p>
          
     </div>
</div>
 

  
</body>
</html>



your question and your code create a paradox. if you want them at the top, then remove the 25% padding that keeps pushing them down. Then, add the following code:

  align-content: flex-start;
  align-items: stretch;
Sponsor our Newsletter | Privacy Policy | Terms of Service