Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a single dot below each character using CSS

Tags:

html

css

I am looking for a way to create the following effect with CSS.

1 dot at each char

I found some solutions for putting dots below the text (white dots below HTML text), but I don't want "dotted underlining", I want every character to have just a single dot below it. Also the dot should increase with the font-size of the text (although if needed, I could mess with JS to fix that).

How could I achieve that?

like image 219
matthy Avatar asked Dec 14 '14 18:12

matthy


People also ask

How do you add symbols in CSS?

The simplest way to add an icon to your HTML page, is with an icon library, such as Font Awesome. Add the name of the specified icon class to any inline HTML element (like <i> or <span> ). All the icons in the icon libraries below, are scalable vectors that can be customized with CSS (size, color, shadow, etc.)

How do I make 3 vertical dots in CSS?

Unicode includes ⠇ which is the Braille symbol for the letter "U". To use, just use the HTML entity &#10247; in your code.

Can we use CSS to style one half of a character?

All you need to do is to apply . halfStyle class to each element that contains the character you want to be half-styled. For each span element containing the character, you can create a data attribute, for example here data-content="X" , and on the pseudo element use content: attr(data-content); so the .


1 Answers

CSS Text Decoration Module Level 3 defines those properties:

  • text-emphasis-style

    This property applies emphasis marks to the element's text. [...]
    The marks are drawn once for each character.

  • text-emphasis-position

    This property describes where emphasis marks are drawn at.

When browsers support that, you will be able to use

text-emphasis-style: dot;
text-emphasis-position: under left; /* or `under right` */

body {
  text-emphasis-style: dot;
  text-emphasis-position: under left;
  -webkit-text-emphasis-style: dot;
  -webkit-text-emphasis-position: under;
  font-size: 300%;
}
ieuw

However, it is not widely supported yet. See caniuse for full details.

Firefox supports it since version 46, or since version 45 if you enable layout.css.text-emphasis.enabled flag.

Chrome supports it since version 25, but needs the -webkit- vendor extension.

Note the standard text-emphasis-position uses a 2-value syntax (for horizontal and vertical writing modes, respectively), but there is a suggestion to allow 1-value syntax too. However, -webkit-text-emphasis-position doesn't allow the 2-value syntax, only the 1-value one.

like image 111
Oriol Avatar answered Sep 19 '22 08:09

Oriol