What is the secret to achieving this distinctive title format?

Exploring a unique title style idea where the text breaks within the line. Unsure if this would be classified as a border or something else. Any suggestions?

Still experimenting and brainstorming, unable to come up with a solution so far.

Answer №1

This solution works seamlessly across various text widths and backgrounds without the need for additional markup. I also incorporated some extra styling and font colors to complement the image.

h1 {
  overflow: hidden;
  text-align: center;
  color: #9cb69c;
  font-family: sans-serif;
  font-size: 16px;
  font-weight: normal;
  letter-spacing: 2.5px;
}

h1:before,
h1:after {
  background-color: #9cb69c;
  content: "";
  display: inline-block;
  height: 1px;
  position: relative;
  vertical-align: middle;
  width: 50%;
}

h1:before {
  right: 1.5em;
  margin-left: -50%;
}

h1:after {
  left: 1.5em;
  margin-right: -50%;
}
<h1>STAY INSPIRED</h1>

Answer №2

Here's an alternative method to solve the problem using flex, padding, and a linear gradient.

body {
  --background-color: #fcfbfa;
  
  background-color: var(--background-color);
}

h2.decorated {
  color: #9ba592;
  display: flex;
  justify-content: center;
  background: linear-gradient(to bottom, transparent calc(50% - 1px), currentcolor 50%, transparent calc(50% + 1px));
}

h2.decorated > div {
  padding: 1rem 2rem;
  background-color: var(--background-color);

  font-family: sans-serif;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
<h2 class="decorated"><div>Stay Inspired</div></h2>

Answer №3

HTML has built-in support for creating lines using the ::before and ::after CSS Selectors. The ::before selector adds content before a specified element, while ::after adds content after a designated element. These pseudo-elements in CSS give you the ability to incorporate content into a webpage without having to include it directly in the HTML code.

For example:

HTML

<h2 class="hr-lines"> Stay Inspired</h2>

CSS

.hr-lines{
  position: relative;
  max-width: 500px;
  margin: 100px auto;
  text-align: center;
}

.hr-lines:before, .hr-lines:after{
  content:" ";
  height: 2px;
  width: 130px;
  background: red;
  display: block;
  position: absolute;
  top: 50%;
  left: 0;
}

Answer №4

I am sharing a helpful solution with you.

.container{
   display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: row;
}
.divider{
 border-top:1px solid gray;
 width: 45%;
  margin: 10px 
<div class="container">
  <div class="divider"></div>
  <h3>Hello</h3>
   <div class="divider"></div>
</div>

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 does not seem to be able to recognize the plus sign (+)

I am currently developing a calculator program and facing some challenges with the addition function. While the other functions ("/", "-", "*") are working fine, the plus ("+") operation seems to be malfunctioning. Here's the snippet of HTML and JavaS ...

Unable to choose multiple sentences within an HTML Page displayed in a UIWebView

I am dealing with an HTML page structured as follows: <html> <body> <div id='0> <span id='0'>Hi </span> <span id='1'>How </span> <span id='2'>Are </span> <sp ...

Building Angular Components in a Single Instance

I am working on an angular webpage that showcases a list of items. Each item is displayed within a div through iteration. Below is the HTML code snippet for this functionality: <div ng-repeat="item in items"> <div class="item-title-section"&g ...

Looking to divide a single full page into four divs of equal size using Bootstrap?

When I set the height of a container to 100% and each content section inside to 25%, why isn't it working as expected? In my browser, each div appears really small and doesn't fill the full page. Can anyone help me figure out what I'm doing ...

Ways to stop two JavaScript files from running at the same time

After combining two JavaScript files, I am facing some issues. The first file handles validation while the second one has an ajax plugin for form submission after validation. When I include these files in the header section, they both run simultaneously. H ...

Three.js is currently rendering a blank canvas in pure white

After following the tutorial at , my browser only displays a white window. I attempted separating the files into js and html, but no luck. What I have already tried: experimenting with adding/deleting the nomodule parameter in the script tag utilizing a ...

Viewing information from a particular database table without relying on identifiers and the objects.all() method

On the profile page, I am looking to showcase various field values from the member table such as fullname, email, contactno, and companyname within the fieldset. In the models.py file for the member table: class Member(models.Model): fullname=models.Ch ...

What is causing the gap to appear between the image and the div element underneath?

I recently encountered an issue where I set up an image to scale to full width, but it was always cut off at the bottom when it extended too high. Here is my current setup: div, img, body { margin: 0; padding: 0; } #image { width: 100%; he ...

Prime NG: Filtering options using label in dropdown menu

I'm facing an issue with my angular project that utilizes prime ng. The problem arises when attempting to perform a column search on rows of dropdown values. When searching for 'Jan', the system fails to retrieve any data, but interestingly ...

Cross origin requests for AngularJS 1.2 are limited to HTTP protocols only

Is it possible to set up an Angular app for external access? I'm currently using a factory. Just a note, I have my app hosted on localhost but making requests to a server within the same network. angular.module('demoApp.factories', []) ...

click to save the document

My goal is to download a csv file when clicked, rather than having it open in the browser I attempted this code <a href="file.csv">download file</a> However, when I click the link, the file opens in the browser instead of downloading. Intere ...

I'm still trying to figure out the property position. Why won't my page scroll? (My first time using HTML)

I'm having an issue with my webpage where it doesn't scroll even when the content exceeds the page length. I've tried adjusting the position settings for the body, html, and div elements but haven't seen any changes. Here is the HTML ...

What is the best way to eliminate headers from appearing in table rows?

I need help figuring out how to eliminate duplicate headers with the css class "thead" that keep appearing in my table rows. Below is the code snippet causing me trouble: for year in years: try: url = 'https://www.pro-football-referen ...

Alpha Screen and Shading Filter

Having trouble with CSS filters in IE8. I have a div with a gradient background that needs to have opacity set to 0, and when hovered over, the opacity should change to 1. Here's my code: #myDiv { filter: alpha(opacity=0); opacity: 0; background:rgba ...

Creating a personalized Chatbot using Azure Conversation

Looking to customize the conversation with an Azure Chatbot (developed with Typescript) on a webchat or directLine channel (changing the color of the conversation, one for the bot and one for the user, for example). I've been following the guidelines ...

Is there a way to simplify this "stopwatch" even more?

Looking for advice on simplifying my JS stopwatch timer that currently only activates once and keeps running indefinitely. As a newcomer to JS, this is the best solution I could come up with: let time = 0 let activated = 0 function changePic() { if(a ...

Create an overlay that completely masks the height of a different element

Having a variety of elements on my screen that require overlays, I find myself facing a challenge. These elements come in different sizes and can be resized while the page is active. Although I managed to position overlays using CSS, the issue of 100% hei ...

Error message stating: "Identifier not defined in Angular 6 ngFor"

Having some trouble with Google's YouTube API. While I'm able to retrieve the data successfully, I'm struggling to display it in a meaningful way. Using a service for the API call, here's the code. My goal is to showcase specific result ...

minor issue with the background in CSS

I am trying to display two icons side by side using HTML code. Here is what I have: <head> <style> .icon_one{ width:25px; height: 20px; background:#ffffff url('icon_one.jpg') no-repeat right top; } .icon_two{ width:2 ...

Seeking guidance on selecting text using XPath

My HTML document contains the following HTML code: <!DOCTYPE html> <html> <head> <title>page XYZ</title> </head> <body> <p><b>bold text</b> some more text </p> <p>< ...