A method for aligning two different font sizes vertically within a single <p> element

My question is, how can I vertically align the following:

Goal: - - | - | - -

Currently, the vertical alignment defaults to baseline.

Current Alignment: _ _ | _ | _ _

HTML:

<div class="moduleResult">
    <p>You have
        <span class="moduleCard">88</span>
        out of
        <span class="moduleCard">88</span>
    correct</p>
</div>

CSS:

.moduleResult{
    width:100%;
    }

p{
    font-family:'Arial';
    font-size:20px !important;
    line-height:30px;
    text-align:center;
    }

.moduleCard{
    font-size:60px !important;
    line-height:60px;
    padding:0 4px;
    }

The text must be centered inside a < div class"moduleResult" >

Here's the Fiddle Link

Answer №1

Visit this link to see the code.

.moduleCard{
    font-size:60px !important;
    padding:0 4px;
    display: inline-block;
    vertical-align: middle;
}

Here is the result:


Remember: Do not use !important unless absolutely necessary.

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

jQuery SlideDown Navigation

Is there a way to implement jQuery code that will display dropdown menu options when the Trials link is clicked? Update: jQuery(document).ready(function () { $("a[href='http://sheep.local/cms/trials']").click(function(e){ e.prevent ...

Swap a jQuery class with another if the class for ul li is currently active

I am currently developing a form builder and I would like to customize the appearance, specifically changing the color of the text. I want the text to be white when the class is set to active, and black when the class is not active. Is there a way to achi ...

Showing the FA icon positioned elegantly at the conclusion of the text within the specified layout

I have a layout similar to the image shown below, where I am looking to place a fa icon above the end of some text. Can someone assist me in designing it like this? https://i.sstatic.net/aJIyV.png ...

Updating an element on the page without having to reload the entire page

I have implemented a functionality on my Laravel page where multiple locations can be saved. Now, I am looking to enhance this feature by allowing users to edit and update location data without refreshing the page. Below is the HTML form structure: <for ...

Removing background color when clicking and dragging using CSS

I'm facing an issue with a resizable div that is cropping part of my webpage. Whenever the mouse moves and clicks on the titles and images, a background color appears, as seen in the picture below. Can someone please help me resolve this problem? htt ...

What is the best way to adjust the size of an svg with CSS?

Here is a question that may be relevant: How can I resize an SVG? I am interested in resizing the arrow created in SVG using CSS. The linked question achieved this through an HTML directive (viewBox="0 0 32 32") Does anyone have any suggestions? #DIV_ ...

What method can be used to trigger quirks mode in Chrome by setting the "BackCompat" property on compatMode?

Currently, I am utilizing Selenium for conducting tests on a client's website (an old site over which I have no control and will not be updated by the client). The issue arises when a specific section of the website only functions correctly when runn ...

Unable to apply the CSS styles on the webpage

I'm having trouble adjusting the CSS for a specific div with the class .cropper inside a component named image-cropper, and I can't figure out why it's not taking effect. Here is an image of the particular div. https://i.sstatic.net/spdJc. ...

Calculating and displaying the output on an HTML page: A step-by-step guide

Within my HTML, I have two values stored in Session Storage: "Money" and "Time". These values are based on what the user inputted on a previous page. For example, if someone entered that they need to pay $100 in 2 days. My goal is to generate a list that ...

Three Pictures Accompanied by Text Below, Which Relocates Next to the Images on More Compact Displays

Although sharing images is not recommended, I believe it would greatly aid in conveying my idea. I have three images that I want to display side by side (blue squares) with text below each one (red squares) on larger screens. For smaller screens, I prefer ...

The status of the 'slider' may be 'undefined'

I'm really struggling to figure out how to resolve this issue, even though I suspect it's a simple fix that's eluding me... Here is the part of my code in TypeScript that's causing the error: const slideLeft = () => { cons ...

Change the color of the menu icon based on the specified HTML class or attribute

I'm trying to create a fixed menu that changes color depending on the background of different sections. Currently, I am using a data-color attribute but I am struggling with removing and adding the class to #open-button. Adding the class works fine, ...

Interactive font-awesome icons within an interactive dropdown menu

I am currently facing an issue with using two Fontawesome icons in a clickable dropdown menu. The dropdown menu does not toggle when I click on the icons directly; however, it works when I click on the padding around them. The example provided by W3schools ...

Creating an HTML table using PHP: A step-by-step guide

Here is a snippet of code that utilizes the explode function to separate values: <?php $data=array(); $Inputfile = file("prod.txt"); foreach ($Inputfile as $line){ $pieces = explode(";", $line); echo $pieces[0]; echo $pieces[1]; echo $piece ...

Issues encountered with PHP integration for Bootstrap carousel

I'm facing a challenge with modifying an existing carousel to load data from an SQL database instead of hardcoding it. After successfully fetching the data using PHP, I noticed that the controls of the carousel are not functioning as expected. Upon i ...

Problem encountered with HTML table formatting

I am struggling to create a table in HTML Click here for image Here is the code I have tried: <table> <tr> <th class="blue" colspan="3">3</th> <th class="orange " rowspan="2">2</th> <th class="blu ...

Is using Pushstate less effective than Hashbangs for caching purposes?

One of the benefits of using HTML5 Pushstate over hashbangs is that Google now encourages its use. The main disadvantage of Pushstate is that it is not supported by non-modern browsers. However, there seems to be a drawback when it comes to caching as well ...

Creating a design with three parallel bars in CSS

For my webpage, I wanted to add an extended flag at the top by creating three horizontal stripes: CSS #main1 div{ width: auto; height: 20px; margin: 0px HTML <div id="main1"> <div style="background-color:red;"></div> <div style="ba ...

Safari 5 experiences delays with JQuery and CSS3 animations

Encountering issues with jQuery animations specifically in Safari 5 on my Windows system. Struggling with a simple image fade slider that still has some flickering. The slider involves click events moving two pages at once, one active page right and the o ...

Ways to duplicate a letter in HTML?

How can a character be printed repeatedly within a table cell using only HTML or HTML and CSS (excluding HTML5)? *(limiting to only HTML or a combination of HTML and CSS) ** The goal is to print the character "." across the entire length of the cell, wit ...