Unusual behavior in CSS with shorthand for fonts

<div class="timer">00:01:05</div>

A 154x30px box is created by the CSS below:

div.timer
{

    font: 700 24px Arial, Helvetica, sans-serif;
}

On the same div element, this CSS generates a 154x19px box.

div.timer
{
    font-weight: 700;
    font-size: 24px;
    font-family: Arial, Helvetica, sans-serif;
}

How is it possible for both sizes to be generated? I have checked the shorthand property and can't figure out what went wrong. The order of attributes seems correct to me.

Answer №1

Using shorthand properties will reset any unspecified values back to their defaults.

In the initial case, adjustments are made to font style, font variant, and line height; the latter being especially influential in modifying box dimensions.

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

What is the solution for setting a regular height to a Bootstrap select when no option is currently selected?

On my webpage, I am incorporating bootstrap select and I want it to be empty initially with a value of "" when the page first loads. This is essential because it is a required field, so if a user attempts to submit the form without making a selec ...

What is the best approach to prevent automatic zoom on a mobile-responsive website?

Looking to optimize my website for mobile viewing. Currently, when viewing on a mobile device, I have to zoom out to see the correct size. How can I ensure it displays properly without needing to zoom out? This is the code snippet I am using: <meta ...

Set an HTML line break after every comma in the array

Here is my array: var a = ['bla bla bla', 'bla bla', 'bla'] I want each value to be displayed on a new line after every comma (<br />), but I am unsure how to achieve this. I attempted the following approach: var a = [& ...

JavaScript isn't functioning properly after UserControl is loaded via Ajax

Thank you, Stilgar for helping me solve my issue. I created a javascript file and placed all my code in it. After adding this file to the UserControl and retrieving the UserControl's html, I used $("#DivID").html(UserControlHTML). Now everything is wo ...

Replace the hyperlink with plain text using JQuery

Is there a way to replace a hyperlink within an li element with different text but without removing the entire list item? <li class="pull-left"> <a href="#" class="js-close-post" data-post-id="1"> Close </a> </li> ...

What could be the reason for the absence of search results in my searchbox?

Can anyone assist me in identifying the issue with my search box? I have created a JavaScript search box that validates input against a predefined keyword list. If a word matches, the "HARMI-SOIL 8.0/15 Result Box" should be displayed, otherwise it should ...

Step-by-step guide on implementing a border-bottom for an active link

Is there a way to apply a border-bottom to btn_articles and btn_posts when one of them is clicked? I attempted to use the active class but it did not have the desired effect. Any suggestions or solutions would be greatly appreciated. let btn_articles = ...

How do I align the Close button to the right in a Bootstrap 5 toast message?

To create a Bootstrap 5 toast, I use the following code: <div id="liveToast" class="toast hide" role="alert" aria-live="assertive" aria-atomic="true"> <div class="toast-header"> ...

What is the most effective way to retrieve the inner HTML of an HTML tag using JavaScript or jQuery?

Let's consider the following code snippet: <p class="question"> this is my paragraph <p> And i'm inside tag in question class <h1> And this is my heading</h1> </p> </p> Now, the challenge is t ...

Tips for resizing tab components in Materials-UI

I am currently developing a basic app that showcases heart rate, blood glucose levels, and other measurements. I am utilizing React and Redux for the development process and incorporating Materials-UI for the user interface. For displaying these metrics, ...

Prevent certain HTML content from being displayed in the input field

My input field behaves like a chat box where users can enter text that gets displayed on the page. However, I've discovered that users can also include HTML tags in their inputs to manipulate the output. For example, entering <b>Hello</b> ...

Is there a method to exempt a particular input field from form validation?

Is there a way to prevent a form validation error message from displaying in other input fields when using an input url field within a rich text editor component (RTE) placed inside a form element? <input type="url" v-model="state.url ...

Harvesting the local image file

Currently, I have implemented a form that allows users to upload images and crop them. The process flow has been established as follows: 1. User uploads the image 2. Server processes the image and sends it back to the browser 3. User crops the image a ...

Create animations for ng-repeat elements without using ng-animate

Can the transition for changing the order of the model array in ng-repeat be animated using only CSS, without using ng-animate? ...

Looking for a way to incorporate dynamic rows within Bootstrap 4?

I am struggling to figure out how to structure my bootstrap rows and columns to line up as shown in the image. I have attempted nesting columns within rows and vice versa but haven't had any success. The yellow and green sections in the picture are d ...

How to import a template from a different webpage in AngularJS

I have a situation where I need to include a template from one HTML page into another because they are both lengthy and it's not practical to keep them on the same page. Therefore, I have decided to separate them for better organization. Here is an ov ...

The importance of white space within email design utilizing table tags in HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html style="opacity: 1;" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv ...

How to Style an Element Based on Fragment Identifier in Href Attribute Using CSS

I've implemented the tabview feature from the YUI3 library. This is how the markup code appears: <div id="demo" class="yui3-tabview-content"> <ul class="yui3-tabview-list"> <li class="yui3-tab yui3-widget yui3-tab-selected"> ...

Prevent DIV from shifting upwards while resizing the window

I am in the process of creating a responsive website, and I encountered an issue with a particular DIV that spans 100% width of the body. Whenever I resize the browser window, this DIV moves upwards and covers the one above it. This problem only occurs whe ...

What is the best way to ensure the button remains fixed at the top when scrolling on a Window?

Can someone help me with fixing a button on top when scrolling the window? I am using JavaScript for this, but suggestions related to JavaScript or jQuery are welcome. See the image provided through this link for clarity on the issue. Here is my button co ...