Tips for aligning text in the middle of a line

I am currently attempting to design a page separator that includes text nestled between two horizontal lines. Despite my efforts, I am struggling to achieve the desired effect of having the text contained within these lines.

You can view my progress in JSFIDDLE by clicking on the following link: My work in JSFIDDLE

Answer №1

Include the following CSS code in your stylesheet:

.centered{
    display: block;
    width: 100%;
    text-align: center;
}

View demo

Answer №2

Here is an alternative solution to the problem, just in case.

HTML

<div class="wrapper">
    <hr class="leftHR" /> 
    <span class="centerText"> OR </span>
    <hr class="rightHR" />
    <div style="clear:both;"></div>
</div>

CSS

.leftHR {
    float:left;
    width: 45%;
}
.centerText {
    width: 9%;
    text-align: center;
}
.rightHR {
    float:left;
    width: 45%;
}
.wrapper {
    width:100%;
}

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

"Enhance the visual appeal of your Vue.js application by incorporating a stylish background image

Currently, I am utilizing Vue.js in a component where I need to set a background-image and wrap all content within it. My progress so far is outlined below: <script> export default { name: "AppHero", data(){ return{ image: { bac ...

The div element with the id "wrapper" is not functioning properly within the box model

I have defined an ID wrapper in CSS: #wrapper { position: relative; background: yellow; -webkit-box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.2); box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.2); width: 960px; padding: 40px 35px 35px ...

Using weasyprint to convert a single HTML page into a PDF

I have encountered a challenge while attempting to convert an HTML page with a single table (containing images or text in the td elements) to a PDF using the Python module weasyprint. The issue I am facing is that weasyprint is inserting page breaks withi ...

Flipping and expanding cards with CSS3

I am attempting to create a layout with a collection of cards/divs within a container. When a card/div is clicked, it should flip horizontally and expand to occupy the entire space within the container (essentially resizing to 100% x 100% when clicked). I ...

The nb-install mixin is not recognized

While working with angular5, I encountered the 'No mixin named nb-install' error when running npm start or serve Module build failed: undefined ^ No mixin named nb-install Backtrace: stdin:13 in E:\mrb_bugfixes& ...

Styling with CSS: Shifting an Element with each adjustment in page width

Within my project, there is a basic div that serves as a navigation bar. Inside this div rests an image portraying a logo. My goal is for the position of the logo to adjust every time the page width is altered. I attempted using media queries for this pu ...

Tips for horizontally centering div elements with container and row class in Bootstrap 5

I am having trouble aligning the section properly in the center, and the div does not have a container class. Is there a bootstrap class that can help with alignment, or do I need to create CSS code to align the items in the div tag? <link href="ht ...

Leverage Html5 to open and retrieve data from an Excel document

Is there a method to access excel file data using HTML5 while uploading the file on the client side? I have come across the use of reader in JavaScript, but unsure how it can be helpful in this scenario. Is there a way to read excel file data seamlessly ...

In HTML5, the semantic tag used for indicating the "subsequent article" is

Having trouble with certain HTML5 elements. Imagine there is a blog post on one side, and a preview of the next post on the other side. Which HTML5 element would you suggest for this setup? Some might argue <nav> makes sense, while others could mak ...

Identify whether the file is suitable for downloading via UIWebview

I am currently working on a project where I need to detect audio files (mp3, mp4, m4a, and wav) when clicking a link within a UIWebview. I have implemented the delegate call -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)re ...

Hamburger Icon in Bootstrap Navbar-Brand is not aligned as expected

I'm currently working on a website project using Bootstrap and have encountered an issue with the navbar component. When the screen shrinks to the breakpoint I've defined (lg), the alignment of the hamburger icon gets disrupted, as shown below. ...

What is the best way to bring HTML files into the dist directory?

When working in my development environment, I utilize the following code: res.sendFile(path.resolve(__dirname,'../Views/setpwd.html'); It functions correctly within the development environment. However, when moving to production, the Views are ...

Swapping IMG depending on breakpoint in Material-UI

I understand how to adjust styling with breakpoints for various properties like height, width, and font size. However, I am struggling to find examples of switching images based on screen sizes. My goal is to replace an image with a different one dependin ...

Create two distinct sections on the screen, each with its own vertical scrollbar for navigation

Using Angular.js and Bootstrap 2.3.2, I am displaying a series of thumbnails on the left side of the screen with a larger version on the right. Currently, both sections share one scrollbar which I aim to change by giving each its own vertical scrollbar usi ...

Can the unquoted HTML literal string syntax from scalatra be implemented in sinatra?

Is it possible to utilize this style in sinatra? get("/") { <html> <body> <h1>Hello, world!</h1> Say <a href="hello-scalate">hello to Scalate</a>. </body> </html> } I'm unsure i ...

Varying spacing among elements with identical classes

I'm facing some styling issues. My goal is to ensure that each h3 tag has the same distance between the bottom border of its container (marked with a pink border) and the bottom border of its parent (indicated in the image below): https://i.sstatic.ne ...

Is it possible for us to view the code contained within a bootstrap class?

The button element has specific classes applied to it with <button class="btn btn-outline-primary">. I am curious about the code within the btn class. ...

Python script to extract the link to a JavaScript file from the href tag in an HTML

Imagine a website similar to the following: This particular website contains links to pdf files referenced by an href tag in the page source, for example: <a href="javascript:$('form_cofo_pdf_view_B000114563.PDF').submit();">B000114563.PD ...

Implementing a PHP script to prompt the user to input two random integers and sum them up on a webpage through $_POST method

My current project involves creating an interactive adding game using PHP and HTML. In this game, the user is required to guess the correct sum of two randomly generated integers. However, I am encountering an issue where each time the user submits their a ...

Loop through the numbers entered into a table field

<table id="Container1Details" cellspacing="15"> <tbody> <tr> <td align="right"> <input name="acidity" type="number" maxlength="4" id="acidity" min="0.112" max="0.152" step="0.001" style= ...