Utilizing CSS for aligning text vertically, especially when dealing with a font that has irritating spacing above it

After purchasing a few fonts for my website project, I encountered an issue with one font in particular called Goodlife Sans. The problem stems from the excessive white space above the font's characters, causing it to take up more vertical space than necessary.

Adjusting the vertical margins has proven challenging due to this extra space. While setting line-height: 1em provides some relief, the line height is measured from the font's top, leading to the cropping of letters' bottoms when set within a block element with overflow: hidden.

The images below illustrate the font's height on its own and with the line-height workaround, with the block element highlighted in red for clarity.

https://i.sstatic.net/VAjKz.png
https://i.sstatic.net/ffL9l.png

Edit: Here's the code

@import url("//hello.myfonts.net/count/2e978a");

@font-face {
    font-family: "GoodlifeSans";
    src: url("fonts/2E978A_0_0.eot");
    src: url("fonts/2E978A_0_0.eot?#iefix") format("embedded-opentype"),
         url("fonts/2E978A_0_0.woff2") format("woff2"),
         url("fonts/2E978A_0_0.woff") format("woff"),
         url("fonts/2E978A_0_0.ttf") format("truetype");
} 
p {
    font-family: "Goodlifesans";
    font-size: 344%;
    background: red;
    text-align: center;
    /*line-height: 1em;*/
    margin: 0;
    padding: 0;
}
body {
    margin: 10px;
    font-size: 80%;
}
<body>
    <p>This is the test title text</p>
</body>

Without modifying the font itself, which may be prohibited by licensing terms, I'm seeking an elegant solution to this issue. Avoiding the need for a parent element with a negative margin every time I use this font would be ideal.

Answer №1

After reaching out to HDV Fonts, they quickly provided me with corrected font files that resolved the problem. Surprisingly, the fonts from myfonts.com had unusual vertical metrics, shedding light on the issue I was experiencing.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Close the ionicPopup by tapping anywhere

Currently, I have implemented an ionicPopup that automatically closes after a certain time limit. However, I am wondering if there is a way to configure it to close with a single or double tap anywhere on the screen instead. While I am aware that setting a ...

Checkbox and radio buttons in JQuery UI are stacked vertically on top of each other, rather than adjacent to each other

Here is the HTML code snippet: <div id="container"> <div id="signals-summary-parameters-radio"> <fieldset> <legend>Row Filter : </legend> <label for="signals-summary-radio-all">All</label> ...

What is the best way to synchronize Bootstrap styles across various HTML files?

Currently, I am part of a group project in school where I am just beginning to learn about html, css, and bootstrap. Each of us has been tasked with creating individual html files to represent web pages for our website, and then we will apply css styles t ...

Utilizing Selenium with Python to Locate Partial Link Text and XPath

Just starting out with the Selenium package and encountering two issues while attempting to determine if a specific text exists on a website. Website address: www.kbc.com I'm trying to locate the text "Investor Relations" on the menu bar, but I am ...

What steps can be taken to resolve a situation in Ruby on Rails where the Navbar drop-down menu fails to display any of its items?

I recently began working on a webpage with a Navbar featuring a drop-down menu to the right. However, when clicking on the trigger to display the drop-down content, none of the items are being shown. For the front-end design, I initially used Materialize ...

The fullscreen API allows for the creation of a full-screen element containing internal elements, while also enabling the functionality

Is it possible to utilize the fullscreen API to make any element fullscreen, even if it contains multiple internal elements, while still maintaining the functionality of dropdowns and other custom elements that may be located in different areas of the page ...

The animated loading image is taking an eternity to actually load

My website is loaded with heavy front-end features and I'm using a loading gif to help with the loading process. However, I've noticed that in Safari, there is a delay before the gif loads after the background does, which takes away from the inte ...

Is it possible to eliminate the default placeholder text from Safari browser?

My goal is to design a form that includes date and time input fields. The placeholder text should move up by X pixels when the user clicks on the field. While the form appears fine in Chrome, there seems to be an issue with overlapping form fields in Safa ...

Guide on creating a perfectly-aligned line within a rectangular shape using CSS

I'm still learning the ropes when it comes to styling. In my web app (created with GWT), I am displaying a grid of results. In one column, I want to showcase a score visualization. The idea is to have a central black line and either a green rectangle ...

Implementing interactive tables with XML data using jQuery

I have been attempting to generate table rows using data retrieved from an xml response. Below is my success function: success: function(response) { $('id', response).each(function() { const row = $('< ...

How can I prevent further input in an input field after making a selection from mat autocomplete in angular?

Hello everyone, I am looking to disable the input field after selecting a value from the drop-down. Additionally, I want to be able to reset the selected value using a reset button. If you need a reference, you can check out Stackblitz: https://stackblitz ...

I'm unable to modify the text within my child component - what's the reason behind this limitation?

I created a Single File Component to display something, here is the code <template> <el-link type="primary" @click="test()" >{{this.contentShow}}</el-link> </template> <script lang="ts"> imp ...

launch a website independently of the original source code

I recently completed a website project using PHP. I'm interested in deploying it without sharing the source code. Is this something that can be done with PHP? Is there a way to convert my website's code into an intermediate form before deploymen ...

Using Jquery to toggle the visibility of a DIV element and adding a blinking effect when it becomes visible

I have a hidden div that is displayed when a link is clicked, and I want it to blink as well. Here is my current setup: The link to display the hidden div: <a class="buttons" href="#" onclick="show(this)">join us</a> The hidden div to be di ...

Padding-left in InfoBox

Currently, I am in the process of developing a map using Google Maps API3 along with the InfoBox extension available at this link I have successfully implemented an overall padding to the Infobox using the following code snippet: var infoOptions = { disa ...

Ways to effortlessly adjust the text of a UILabel to smoothly change in size as the font size changes in iOS

I have been searching for a solution to this issue, but so far I haven't found one that works for me. What I'm looking for is the ability to adjust the font size and frame of a UILabel as I move a slider. The initial text on the labels is "atten ...

React Href is not functioning as expected in relative paths

Recently, I delved into React apps and managed to create one with a router. Everything was smooth sailing in dev mode until I tried running index.html from the build folder after npm run build. It seems like all the href links are broken. I suspect somethi ...

What is the proper way to place a newly added element using absolute positioning?

Currently, I am in the process of developing a tooltip feature. This function involves adding a div with tooltip text inside it to the element that is clicked. However, I am facing a challenge in positioning this element above the clicked element every tim ...

Ways to avoid unintentional removal of contenteditable unordered lists in Internet Explorer 10

How can I create a contenteditable ul element on a webpage while avoiding the issue in Internet Explorer 10 where selecting all and deleting removes the ul element from the page? Is there a way to prevent this or detect when it happens in order to insert ...

Tips for adjusting the font size options within the Autocomplete feature of Material UI Version 5

Is there a way to adjust the font size of the drop-down items? I have tried various methods to change the font size, including: How do I change Material UI Autocomplete font size? How to change fontsize of options in Material ui autocomplete? Unfortuna ...