Reputation: 13
I appologize if this question has already been posted. I looked for hours and couln't find it. I'm pretty new to HTML and CSS so I also appologize for my awful code.
I'm trying to align a H3 header directly under an H1 heading.
My code is:
<body>
<div class="header">
<img class="flag" src="./images/MINFLAG.png">
<h1>Placeholder txt</h1>
<h3 class="motto"><em>"Website motto"</em></h3>
</div>
and CSS:
.header{
font-size: 15px;
background-color: pink;
color: deeppink;
text-align: left;
font-family: Candara;
background-image:;
padding-bottom: 0.5%;
border-radius: 1%;
}
.moto{
}
.flag{
height: 95px;
width: 150px;
text-align: center;
display: inline-block;
padding-top: 10px;
padding-right: 5px;
padding-left: 12px;
vertical-align: middle;
}
.header h1{
line-height: 9%;
display: inline-block;
padding-left: 3%;
}
.header h3{
padding-left: 20%;
}
<div class="header">
<img class="flag" src="./images/MINFLAG.png">
<h1>Placeholder txt</h1>
<h3 class="motto"><em>"Website motto"</em></h3>
</div>
The H3 is significantly lower than everything else, and i would like it to be vertically centered with the flag.
Edit: Here's a mockup thing. I only use H3 as a style choice because I'm not really sure what else to do.
Upvotes: 1
Views: 113
Reputation: 11
You should make it an h2 to follow semantic order of headers but you can style the h2 as an h3 if that is really what you want.
Upvotes: 0
Reputation: 2899
.header{
font-size: 15px;
background-color: pink;
color: deeppink;
text-align: left;
font-family: Candara;
background-image:;
padding-bottom: 0.5%;
border-radius: 1%;
display:flex;
}
.moto{
}
.flag{
height: 95px;
width: 150px;
text-align: center;
display: inline-block;
padding-top: 10px;
padding-right: 5px;
padding-left: 12px;
vertical-align: middle;
}
.header h1{
width:100%
padding-left: 3%;
}
.header p{
padding-left: 20%;
}
<div class="header">
<img class="flag" src="./images/MINFLAG.png">
<div>
<h1>Placeholder txt</h1>
<h3 class="motto"><em>"Website motto"</em></h3>
</div>
</div>
You just need to wrap both your h1 and h3 tags into another div.
Use the flex layout then.
Here is an example.
`https://codepen.io/Utsav91/pen/GzaBox`
Upvotes: 1
Reputation: 15594
Did few changes but you might need to customize.
.header {
font-size: 15px;
background-color: pink;
color: deeppink;
text-align: left;
font-family: Candara;
background-image: ;
padding-bottom: 3%;
border-radius: 1%;
}
.flag {
height: 95px;
width: 150px;
text-align: center;
display: inline-block;
padding-top: 10px;
padding-right: 5px;
padding-left: 12px;
vertical-align: middle;
float: left;
}
.header p {
padding-left: 20%;
}
<div class="header">
<div>
<img class="flag" src="https://upload.wikimedia.org/wikipedia/en/thumb/a/a4/Flag_of_the_United_States.svg/1280px-Flag_of_the_United_States.svg.png">
<h1 align="center">Placeholder txt</h1>
<h3 align="center"><em>"Website motto"</em></h3>
</div>
</div>
Upvotes: 0
Reputation: 617
.header{
font-size: 15px;
background-color: pink;
color: deeppink;
text-align: left;
font-family: Candara;
background-image:;
padding-bottom: 0.5%;
border-radius: 1%;
display: flex;
}
.flag{
height: 95px;
width: 150px;
text-align: center;
display: inline-block;
padding-top: 10px;
padding-right: 5px;
padding-left: 12px;
vertical-align: middle;
}
.content {
padding-left: 15px;
display: flex;
flex-direction: column;
justify-content: center;
}
.header h1{
margin: 0;
}
.header h2 {
margin: 0;
text-align: center;
}
<div class="header">
<img class="flag" src="./images/MINFLAG.png">
<div class="content">
<h1>Placeholder txt</h1>
<h2 class="motto"><em>"Website motto"</em></h2>
</div>
</div>
Upvotes: 0
Reputation: 1343
Just wrap your header elements and apply appropriate styling.
.header {
font-size: 15px;
background-color: pink;
color: deeppink;
text-align: left;
font-family: Candara;
background-image: ;
padding-bottom: 0.5%;
border-radius: 1%;
}
.flag {
height: 95px;
width: 150px;
text-align: center;
display: inline-block;
padding-top: 10px;
padding-right: 5px;
padding-left: 12px;
vertical-align: middle;
}
.header .header-text {
line-height: 9%;
display: inline-block;
padding-left: 3%;
vertical-align: center;
}
.header p {
padding-left: 20%;
}
<div class="header">
<img class="flag" src="./images/MINFLAG.png">
<div class="header-text">
<h1>Placeholder txt</h1>
<h3 class="motto"><em>"Website motto"</em></h3>
</div>
</div>
Upvotes: 0
Reputation: 1888
Like this?
.header {
font-size: 15px;
background-color: pink;
color: deeppink;
text-align: left;
font-family: Candara;
background-image: ;
padding-bottom: 0.5%;
border-radius: 1%;
}
.moto {
}
.flag {
height: 95px;
width: 150px;
text-align: center;
display: inline-block;
padding-top: 10px;
padding-right: 5px;
padding-left: 12px;
vertical-align: middle;
}
.header h1 {
line-height: 9%;
display: inline-block;
padding-left: 3%;
}
.header p {
padding-left: 20%;
}
<div class="header">
<img class="flag" src="./images/MINFLAG.png">
<h1>Placeholder txt</h1>
<h3 class="motto"><em style="padding-left:4%;">"Website motto"</em></h3>
</div>
Upvotes: 0