CSS - font with dashed color styling

I need to display text on a webpage that has the following appearance:

https://i.sstatic.net/vFA2A.png

The font should have two alternating colors. Can this be achieved? The solution needs to be compatible with all web browsers.

Answer №1

A great way to add custom fonts to your webpage is by utilizing a proper font file.

@font-face {
    font-family: myCustomFont;
    src: url(custom_font.ttf);
}

Answer №2

Utilizing CSS, it is possible to achieve this effect without the need for a custom font in Google Chrome and other WebKit browsers by using -webkit-background-clip.

h1 {
    font-family: sans-serif;
    font-size: 300%;
    background: repeating-linear-gradient(
        135deg,
        #3f3f3f,
        #3f3f3f 2px,
        #7f7f7f 2px,
        #7f7f7f 4px
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
<h1>Your text here</h1>

It should be noted that this will only appear as text on top of a striped background in browsers like Firefox or IE.

This article provides insight into -webkit-background-clip and some alternatives for different browsers.

This article offers guidance on creating striped backgrounds using pure CSS3.

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

Tips on how to properly position the navigation bar within a wrapper element

I'm having trouble fixing the navigation bar at the top of the wrapper when scrolling down. However, when I try using position: fixed in the #nav ul, the navigation bar extends beyond the wrapper. Below is my HTML code, where the nav bar should be con ...

Struggling to properly align div in the center

I've been struggling to properly center a div inside another div, but instead of being centered it appears shifted to the right. I've experimented with different positioning combinations and techniques from various sources, yet I haven't fou ...

What is the best way to add additional buttons to my React App after the initial button has been clicked?

Currently, I am in the process of developing a CSV file loader that converts data into JSON format. The loader will consist of three buttons: 1. The first button allows me to select a file from my computer and load the CSV data for conversion to JSON. 2. ...

Searching for an array of strings in an express.js application

My concern is related to working with an array of strings. The specific situation involves: let search = ["user","country"]; In order to retrieve data from a MySQL database, I am looking to utilize the LIKE operator. An example of wha ...

``Is there a faux pseudo element lurking within Firefox?"

I have a question regarding Firefox. I often notice some peculiar pseudo elements in the debugger tool, displayed as a rectangle with a dot inside: In this particular case, I cannot fathom why there would be a pseudo element in the middle of a list. Whe ...

Navigating the parent-child hierarchy in Three.js

Two cubes were created with specific dimensions. The first cube had a width of 2083, height of 1987, and depth of 0. The second cube had a height of 40, width of 80, and depth of 0. The second cube was then positioned inside the first cube as its child wit ...

Exploring the Dev Tools Console feature in Excel for Windows

I have developed an Excel add-in using AngularJS. I utilize <div ng-show="isLoggedIn">...</div> and <div ng-show="!isLoggedIn">...</div> to manage different content based on the value of $scope.isLoggedIn. While it functions well i ...

Positioning elements next to each other in jQuery on mouse over - while also addressing scrolling issues in a div

After tinkering with this interesting concept of mouseover combined with absolute positioning divs on a jsFiddle, I encountered some unexpected results. The code was inspired by a stackoverflow thread on positioning one element relative to another using j ...

What is the method to change between input sources in php?

Imagine this scenario: when a user clicks on a specific button, I want them to be presented with either a dropdown list or an input field. This decision would allow the user to choose an existing item or create a new one. <select name="choose[rowId]"&g ...

Manipulate a table using Jquery's find() method to insert a cell populated with information from an array using before()

My current challenge involves inserting a column of cells with data from an array. Despite attempting to use a for loop, all the cells end up displaying the same data from the array. What I really want is for each new cell to show 'row_header1', ...

Enhancing nested return efficiency

Consider the following two JavaScript functions: function (){ return _.includes(someLongArray, value) && someSimpleValue; } VS function (){ return someSimpleValue && _.includes(someLongArray, value); } Which function will have bett ...

Exploring the Link Between jQuery and HTML

Is it possible to connect between an HTML file and a jQuery file? Here is an example scenario: jquery-test.js: $(document).ready(function(){ $('#inputForm').submit(function(){ $('#inputForm :text:not("#submit")').each(func ...

Create an input field with a dynamic and exclusive identifier using the DataTables plugin

I am having trouble creating unique IDs for each input field based on the number of rows Here is the code snippet: $(document).ready(function() { var oTable = $('#jsontable').dataTable(); //Initialize the datatable $.ajax({ url ...

Developing a matrix arithmetic parser using JavaScript

Currently, I am in the process of developing a program that can solve matrix equations. My main focus right now is on making sure the parser functions correctly. However, I am feeling lost and unsure of where to begin. In my program, I utilize an array of ...

Issue with Modal functionality in Internet Explorer 9

Check out the URL of a page that functions properly in Firefox, Chrome, and Safari, but is experiencing issues in IE 9. Upon page load, a modal displays a banner. The modal I am using can be found at Although the script appears to be correct, I have not ...

What could be causing this test to fail when testing my API endpoint?

Why am I encountering this error? Uncaught exception: Error: listen EADDRINUSE: address already in use :::3000 import supertest from "supertest" import axios from "axios" import app from ".." const request = supertest(app ...

Is it accurate to categorize every ajax request (using xmlhttprequest) as a web service request?

Recently, I began incorporating AngularJS with Spring MVC as my backend. I have been utilizing $resource to connect with my backend. Given that this is a restful service and $resource operates using ajax, I find myself questioning: 1) Is ajax solely used ...

What is the best way to assign attributes to multiple HTML elements using an array?

Seeking assistance to hide various sections in my HTML file upon button click, with the exception of one specific section. Encountered an error message: Uncaught TypeError: arr[i].setAttribute is not a function Here's a snippet of my code: const hide ...

Unable to add new tags in Vue multiselect component

Currently, I am utilizing a Vue Multiselect instance with two functions. One function interacts with the database to provide autocomplete functionality, which is working successfully. The second function allows for adding new tags that are not present in t ...

Choose a table by using jQuery excluding the data in the first column

Does anyone know how to extract data from an HTML table using jQuery? In my specific case, I need to retrieve the table contents without including the first column. This is because I want to export the table to an Excel file, but the first column contains ...