Modifying<strong>superscript</strong> design

Is there a way to change the style of <sup> elements using CSS without removing them from the HTML code? I want to make them look like regular text.

Basically, I want the result of

<div>Some <sup>random</sup> text.<div>

to appear as

<div>Some random text.<div>

Do I need to reverse the effects of the superscript or is there a more efficient way to achieve this? Your help is appreciated. Thank you!

Answer №1

You can set the sup tag to inherit its font-size and vertical-align properties from its parent element (the div).

sup {
  font-size: inherit;
  vertical-align: inherit;
}
<div>Some <sup>random</sup> text.<div>

This approach will still work even if the parent element has additional styling applied to it.

div {
  font-size: 10px;
}

sup {
  font-size: inherit;
  vertical-align: inherit;
}
<div>Some <sup>random</sup> text.<div>

Answer №2

To achieve the desired effect, the sup tag utilizes font-size and vertical align properties. However, it is possible to revert these values back to their defaults.

http://jsfiddle.net/q8urty56/

sup {
    font-size: initial;
    vertical-align: initial;
}

Answer №3

If you want to achieve this effect, simply apply the following CSS style to the 'sup' element.

sup{
  font-size: initial;
  vertical-align: baseline;
}

You can view the code in action by following this link: http://jsbin.com/zuhasoqide/edit?html,css,output

Answer №4

As stated by Mozilla, the default styling for the sup element includes:

vertical-align: super;
font-size: smaller;
line-height: normal;

Ensure to reset these three properties as needed.

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

Perfecting the Radio Button Selection (because why not?)

Struggling to round the outer corners of three inline squared radio buttons with unique IDs. Need help fixing my CSS syntax - I can get each button to individually round its corners, but not just radio1 and radio3's outer corners. Check out the issue ...

Is there a way to locate a file by inputting a partial name?

How can I create a search bar that allows me to find files in a folder (songs) by typing only part of the song name? For example, if I type "he," it should show results like "hello" and "hey." Is there a way to take my input and search for it within file n ...

After loading ajax content onto the page, the scroll bars fail to appear

I am currently constructing a website that loads page content through ajax. Everything seems to be functioning perfectly, except for a peculiar issue I have encountered in Chrome and Safari. Surprisingly, it is working flawlessly in IE! The problem lies i ...

Ways to prevent images from vanishing when the mouse is swiftly glided over them

Within the code snippet, the icons are represented as images that tend to disappear when the mouse is swiftly moved over them. This issue arises due to the inclusion of a transition property that reduces the brightness of the image on hover. However, when ...

Is it recommended to directly embed the CSS into the HTML of a specific view?

I have been immersed in a personal project that involves multiple HTML views and CSS files. Up until now, I have been consolidating all the CSS files into one "global.css" and linking this file to my index.html. However, with some friends joining the proje ...

What is the method to set precise values on a range slider?

Currently, I am developing a PHP website that requires a slider for displaying the years of publications. In essence, I need the slider to navigate through the different years when the publications were released. // Database connection and other PHP code ...

"Utilize Angular's functionality to include labels for checkboxes generated using *ngFor directive

I am currently working with Angular 5 My goal is to generate multiple checkboxes using the code below and provide them with labels <input type="checkbox" *ngFor = "let v of options[0].options" [value]="1" [name] = "1"> Typically, when working with ...

Experiencing problems with the calling convention in JavaScript

Here is a snapshot of the code provided: If the function testFields at Line:3 returns false, then the program correctly moves to Line:21 and returns the value as false. However, if testFields returns true, the program proceeds to Line:4, but instead of ex ...

Utilize a variable within an HTML attribute

Currently utilizing Angular and I have the following HTML snippet <input onKeyDown="if(this.value.length==12 && event.keyCode!=8) return false;"/> Is there a way for me to incorporate the variable "myNum" instead of the ...

Adjusting the content of a span causes the parent element to shift to the left

I'm having trouble finding a solution to a specific issue that seems to be only affecting Chrome. Whenever I try to replace the text in a span element, it causes the parent anchor to shift left. You can see a demonstration of this problem here: http:/ ...

The Bootstrap dropdown functionality is not working properly and fails to open when clicked

Can anyone help with this Navber code issue? <nav class="navbar navbar-expand-lg navbar-light" style="background-color: #FDFEFF;"> <div class="collapse navbar-collapse justify-content-center" id="navbarNav"> <a class="navbar-brand" ...

Classes that are designed to be written on a single

A fellow team member recently made an addition to our project. <ol class="numbered-list list-inside" start="1"> .numbered-list { list-style-type: decimal; } .list-inside { list-style-position: inside; } Is there a problem with this code, ...

What steps are involved in creating a webpage cleaner similar to Arc90's Readability or Instapaper?

Curious about cleaning up an HTML page to present it in a more polished manner - eliminating clutter and restructuring the main text for better readability, similar to resources like or Instapaper. Would the process involve basic page parsing and filteri ...

Using a jQuery event to apply styles with CSS

Hello, I am using jQuery Easy UI on my webpage but feeling a bit confused. I want to create an input field that looks like a tagging field - meaning when the user types a separator character (let's say a comma), the word being typed will have its CSS ...

Adding a popover to a cell in a table: A step-by-step guide

Currently, I am attempting to display data in a single cell when hovered over using a popover. The problem I'm facing is that adding the data-toggle inside the td tag has no effect. Each cell is structured like this: <td style="padding: 0px; back ...

transferring data from one HTML file to another using a loop with technologies such as HTML,

As a beginner in front end development, I am finding it a bit challenging at the moment. Here's what I have so far: 1 main HTML file (index.html) 1 JavaScript file (something.js) 2nd HTML file (something.html) Main HTML: <!DOCTYPE html> < ...

Obtaining the count of a specific column in Angular 6 by grouping objects based on the same value in an array

In TypeScript, I have an array of objects and I am using a foreach loop. The array contains 2 columns with a progress value of 100, while the rest have values less than 100. My goal is to calculate the count of columns with a progress value of 100, which ...

Polymer: Basic data binding is not functional in the second element

After dedicating 6 hours to this problem, I still can't seem to find a solution. Below is the code snippet from index.html: <flat-data-array availableModes="{{modes}}" id="dataArray"></flat-data-array> <flat-strip-view availableModes=" ...

How can I achieve an endless scrolling text effect within a square on a webpage using CSS?

My header currently displays a horizontal infinite scroll of text, but I am looking to achieve a square pattern wrapping around the page. Can you provide guidance on how this can be accomplished? Below is the code snippet I am working with: .marquee { ...

JavaScript encountered an issue when trying to display HTML content

Through my PHP code, I am attempting to create a popup window that displays the content of an HTML file. However, after adding script tags, no HTML content is displayed. When I tried echoing out $row2, only the word 'array' appeared on the screen ...