HTML Fonts dont match on different elements - html

I have an input and h4 element. I'm using the same font and font size but they do not look the same.
#font-face {
font-family: sansReg;
src: url(../fonts/openSansReg.ttf);
}
.global-message h4 {
/*for the chat messages*/
margin: 0;
font-size: 15px;
font-family: sansReg;
}
.input {
/*for the chat message input*/
padding-left: 10px;
box-sizing: border-box;
font-size: 15px;
font-family: sansReg;
border: 0;
border-radius: 2px;
background-color: white;
margin: 0 auto;
outline: 0;
background-repeat: no-repeat;
background-position: 2px 3px;
display: block;
}
<div id="chat-box">
<div id="chat-list-container">
<ul id="chat-messages">
<li class="global-message">
<h4>Will: Anyone wanna play?</h4>
</li>
<li class="global-message">
<h4>George: Hey guys!</h4>
</li>
<li class="global-message">
<h4>Jessica: How do i start a game?</h4>
</li>
</ul>
</div>
<input id="chat-message" class="input" type="text" placeholder="Message" maxlength="32" />
</div>
So as you can see I have some h4's to fill the chat and my input below it and I have used the same font but it looks like this:

The h4 element has font-weight bold by default; therefore, if you want to make the input look the same way, you have to add font-weight: bold; to your input style.
Or, if you want to make h4 look like the input, you can remove the bold by setting it to normal font-weight: normal; on the h4 element.
Examples:
*{
font-family: Helvetica, Arial;
}
.normal {
font-weight: normal;
}
.bold {
font-weight: bold;
}
<h4>default bold</h4>
<h4 class="normal">light</h4>
<input value="default light"><br>
<input value="bold" class="bold"><br>

Headings have different default values. In your case you compare an h4 with a paragraph. As you can see below there is a big difference. What you need is to add font-weight: bold; to your .input-class.
H4 default values
h4 {
display: block;
font-size: 1em;
margin-top: 1.33em;
margin-bottom: 1.33em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
}
Paragraph default values
p {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
}
A "good" practice (or what I try to remember to do) is to copy all default values in for each CSS-element I create. By doing so I have access to all properties and not only those I want to change.

Add css properties font-weight: bold; font-size: 1em to the input field. The font will look identical to the h4 font.

Try adding this to your css:
.global-message h4{
font-weight: normal;
}
It should make all the font look the same.

Related

Why I can't change the font size of last h3 only

I'm making a web page containing multiple titles. I have a problem and that is I can't change the font size of h3 (last one) and if I did the whole font sizes of other titles changes too. I want to know why and how to solve this.
This the code
.join_us {
width: 100%;
margin-top: 50px;
}
.join_us h3 {
font-size: 20px;
font-family: 'sans-serif';
font-weight: bold;
text-align: center;
color: #2D2D2D;
}
.join_us .create_account_container {
width: 400px;
height: 60px;
margin-left: auto;
margin-right: auto;
background-color: #0EBA00;
margin-top: 40px;
text-align: center;
}
.join_us .create_account_container a {
text-decoration: none;
line-height: 60px;
font-size: 25px;
font-family: 'sans-serif';
font-weight: bold;
text-align: center;
color: #FFF;
}
.invite_for_use_section h1 {
font-size: 28px;
font-family: 'sans-serif';
color: #000;
font-weight: bold;
text-align: center;
line-height: 40px;
margin-top: 30px;
}
.invite_for_use_section h3 {
font-size: 13px;
font-family: 'sans-serif';
font-weight: bold;
text-align: center;
color: #2D2D2D;
}
<div class="join_us">
<h3>JOIN OVER 10,000 SMART AFFILIATE MARKETERS! GET STARTED NOW...</h3>
<div class="create_account_container">
CREATE MY ACCOUNT
</div>
</div>
<div class="invite_for_use_section">
<h1>
Use Our Secret Tool and Boost Your Commissions Up to 5X More While Cutting Your Workload To Shreds!
</h1>
<br>
<h3>
Over 10,000 (and growing) People Can't Be Wrong!
</h3>
</div>
The page also contain header which contain h1 titles didn't include it because I think it has no relation to this problem.
if you want to change the font size of a specific element, try using id's. You can assign an id to an object, like this:
<h3 id = "over10">
Over 10,000 (and growing) People Can't Be Wrong!
</h3>
And to apply styling to that object, in your CSS, you can simply reference that object with a hashtag (#) with its id name, like this:
#over10 {
font-size: 33px;
font-family: 'Arial';
font-weight: bold;
text-align: center;
color: #2D2D2D;
}
I plugged it into code pen and had no problems changing the font size. The only thing I can think of is that H3 is setting a font size which might be overriding the CSS. Trying using a div instead.
I've fixed it, thnx guys, i changed the h3 to h5 and h4 ,i think css doesn't allow you to make the font size of an h3 bigger than the font of h1...

CSS - aligning H1 with a span symbol

I'm styling the section headings for a website and I can't quite get a span symbol and a H1 heading to align properly. This is how it looks on the site -
Annoyingly, when I've come to include the code in this snippet the two elements seem to align. When I check the console the span element seems to have a buffer around the symbol which prompts it slightly out of line as you can see in the image. I'm using bootstrap for the site, could this be a hidden rule that I'm missing?
.secthead span {
font-weight: bolder;
font-size: 80px;
font-family: 'Gotham-Medium', sans-serif;
}
.secthead h1 {
font-size: 50px;
font-family: 'Gotham-Medium', sans-serif;
color: #000;
text-align: left;
padding: 0 0 20px 20px;
}
.secthead h1, span {
display: inline-block;
}
<div class="secthead"><span style="color: rgb(255,128,55);">+</span><h1>Who We Are</h1></div>
Just use vertical-align: middle; in both tag & remove padding from bottom in h1 tag. check updated snippet below..
.secthead span {
font-weight: bolder;
font-size: 80px;
font-family: 'Gotham-Medium', sans-serif;
}
.secthead h1 {
font-size: 50px;
font-family: 'Gotham-Medium', sans-serif;
color: #000;
text-align: left;
padding: 0 0 0px 20px;
}
.secthead h1, span {
display: inline-block;
vertical-align: middle;
}
<div class="secthead"><span style="color: rgb(255,128,55);">+</span><h1>Who We Are</h1></div>
You could use a height and line-height.
.secthead span {
font-weight: bolder;
font-size: 80px;
font-family: 'Gotham-Medium', sans-serif;
}
.secthead h1 {
margin: 0;
font-size: 50px;
font-family: 'Gotham-Medium', sans-serif;
color: #000;
text-align: left;
padding: 0 0 20px 20px;
line-height: 92px;
}
.secthead h1, .secthead span {
height: 92px;
display: inline-block;
vertical-align:top;
height: 92px;
}
<div class="secthead">
<span style="color: rgb(255,128,55);">+</span>
<h1>Who We Are</h1>
</div>

Removing space between h1 and h2

I have stumbled across a problem that I can not seem to solve in any way, maybe I am using divs in a wrong way?
.greeting h1 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 100px;
text-align: center
}
.greeting h2 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 35px;
line-height: 0px;
text-align: center
}
<div class="greeting">
<h1>Hi.</h1>
<h2>Select a group</h2>
</div>
This is the outcome:
I want to decrease the space between my <h1> and <h2>, and I found out that the way to do that was to set line-height in h1 to 0px.
But as I do that my entire page moves up like so:
I want to keep the text at the same position as it was before I change the line-height. I am suspecting that I am using the div class function wrong. This is more of theoretical question.
headings h1 to h6 have margin by default, so you need to reset it, setting: margin:0.
.greeting h1 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 100px;
text-align: center;
margin: 0
}
.greeting h2 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 35px;
text-align: center;
margin: 0
}
<div class="greeting">
<h1>Hi.</h1>
<h2>Select a group</h2>
</div>
HTML heading tags have some default CSS values applied in most browsers. Following are the values of h1 and h2 that are applied to them by default, so you need to override the margin-bottom of h1 and margin-top of h2 if you want to decrease the spacing between your h1 and h2.
h1 {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
}
h2 {
display: block;
font-size: 1.5em;
margin-top: 0.83em;
margin-bottom: 0.83em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
}
.greeting h1 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 100px;
text-align: center;
margin-bottom: 0;
}
.greeting h2 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 35px;
line-height: 0px;
text-align: center;
margin-top: 0;
}
<div class="greeting">
<h1>Hi.</h1>
<h2>Select a group</h2>
</div>
Just add the following lines
.greeting h1 {
margin:0px;
line-height:35px;
}
.greeting h2 {
margin:0px;
line-height:35px;
}
If you just want you to assign the margin only for this block you do not need to define it globally you can just do the same this using inline CSS
<h1 style="margin-bottom: 0">Hi</h1>
<h2 style="margin-top: 0">Select a group</h2>

CSS issue with span

I am trying to recreate a logo with plain text and CSS no images, the issue I have I can't seem to get padding to 0 around the text so that top and bottom text are only 2-5px apart.
Also is it possible to have them one on top of the other but not the have BIG TITLE CSS to
display:block
instead only to wrap around the text.
jSFiddle: http://jsfiddle.net/theStudent/ag60a6hs/
CSS:
/* FONT IMPORT */
#import url(http://fonts.googleapis.com/css?family=Roboto+Condensed:400,300,700);
.logo_large_txt{
color: #2faed9;
margin:0 0 0 0;
padding: 0 0 0 0;
font-family: 'Roboto Condensed', sans-serif;
font-weight: 700;
font-size: 36px;
background-color: #000;
white-space: nowrap;
display: block;
}
.logo_small_txt{
color: #c2c2c2;
padding: 0;
margin: 0;
font-family: 'Roboto Condensed', sans-serif;
font-weight: 700;
font-size: 16px;
background-color: #000;
white-space: nowrap;
}
HTML:
<div>
<span class="logo_large_txt">BIG TITLE</span>
<span class="logo_small_txt">SMALL CAPS</span>
</div>
Thanks
This isn't a padding issue, it's a line-height issue. Set line-height: 1em; on the relevant elements (those with text in them) and see how the height of the element now equals the size of the text.
Perhaps adding line-height might help, for example line-height:50% for logo_large_txt.
Yes this is line-height issue. You could set line-height to 1 or less on div and see the result.
For second part You should add <br /> tag between <span> tags.
fiddle or preview:
/* FONT IMPORT */
#import url(http://fonts.googleapis.com/css?family=Roboto+Condensed:400,300,700);
.logo_large_txt{
color: #2faed9;
margin:0 0 0 0;
padding: 0 0 0 0;
font-family: 'Roboto Condensed', sans-serif;
font-weight: 700;
font-size: 36px;
white-space: nowrap;
}
.logo_small_txt{
color: #c2c2c2;
padding: 0;
margin: 0;
font-family: 'Roboto Condensed', sans-serif;
font-weight: 700;
font-size: 16px;
white-space: nowrap;
}
div.logo {
line-height: 0.8;
display: inline-block;
background-color: #000;
}
<div class="logo">
<span class="logo_large_txt">BIG TITLE</span><br />
<span class="logo_small_txt">SMALL CAPS</span>
</div>

Why can I get no satisfaction trying to add margin or padding between an image and some text?

I want an image on the left and three pieces of text on the right. I've got that, but trying to add some space between them is proving to be an exercise in futility. I've tried adding both padding-left and margin to the css, but they ignore them like a cheerleader does a nerd.
The jsfiddle is here: http://jsfiddle.net/GwYJH/
Here's my HTML:
<a id="mainImage" class="floatLeft" href="https://rads.stackoverflow.com/amzn/click/com/1456334050" rel="nofollow noreferrer"><img height="200" width="160" src="http://ecx.images-amazon.com/images/I/51ETjedyMAL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA300_SH20_OU01_.jpg"></img></a>
<div class="category">Picaresque Satire</div>
</br>
<div class="title">the Zany Time Travels of Warble McGorkle</div>
</br>
<div class="author">Blackbird Crow Raven</div>
</br>
...and the CSS:
body {
background-color: black;
}
.floatLeft {
float: left;
}
.category {
display: inline-block;
font-family: Consolas, sans-serif;
font-size: 2em;
color: Orange;
padding-left: 25;
margin: 25;
}
.title {
display: inline-block;
font-family: Calibri, Candara, serif;
color: Yellow;
}
.author {
display: inline-block;
font-family: Courier, sans-serif;
font-size: 0.8em;
color: White;
}
I also want each piece of text to wrap if the viewbox narrows. IOW, "Picaresque Satire" should become:
Picaresque
Satire
...if there's not enough space to fit on one line; what it's doing now is moving below the image if it runs out of space (then it will break as I want it to if it gets squished even more).
#mainImage {
margin-right:15px;
}
.category p {
word-wrap:break-word;
}
Demo here:http://jsfiddle.net/GwYJH/8/
How the word wraps (i.e. if it wraps to the right hand side of the image or below it) is wholly dependent on the width of the containing element.
I have some suggestions for you. Fist of all, use this code to get the spaces.
.floatLeft {
float: left;
padding-left: 25px;
margin: 25px;
}
The, set the width to the .category, so you wrap the text
.category {
display: inline-block;
font-family: Consolas, sans-serif;
font-size: 2em;
color: Orange;
padding-left: 25;
width:30px;
}
jsfiddle
Non-zero padding and margin values require a unit to be specified. I assume you wanted pixels:
padding-left: 25px;
margin: 25px;
http://jsfiddle.net/GwYJH/6/
Old versions of IE would allow you to omit the unit, but modern standards compliant browsers do not.
You dont have (px) defined on the padding-left and margin. Remove margin and only use padding-left on all of the divs.
Use this code instead:
.category {
display: inline-block;
font-family: Consolas, sans-serif;
font-size: 2em;
color: Orange;
padding-left: 25px;
}
.title {
display: inline-block;
font-family: Calibri, Candara, serif;
color: Yellow;
padding-left: 25px;
}
.author {
display: inline-block;
font-family: Courier, sans-serif;
font-size: 0.8em;
color: White;
padding-left: 25px;
}