Arrange words within a right-to-left div containing both right-to-left and left-to-right languages as well as numbers

In my Right To Left div, I want to display the following sentence with the words in reverse order:

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

I am struggling to achieve this formatting.

So starting from the Right to Left:

  1. שלום1
  2. English Words
  3. 9000
  4. עולם2

Here is the HTML code:

    <div class="rtl_div">
      <p>
        שלום1 English Words 9000 עולם2
      </p>
      <p>
        <span class="position_1">שלום1</span>
        <span class="position_2">English Words</span>
        <span class="position_3">9000</span>
        <span class="position_4">עולם2</span>
      </p>
    </div>

And here is the CSS styling:

.rtl_div{
  direction: rtl;  /* This must remain right to left */
 }

Check it out on jsfiddle: https://jsfiddle.net/pf8g2o6w/

Note: As suggested by Tushar, you can resolve any issues by changing elements' display from inline to block, but if you prefer to stick with display inline, use this CSS:

span { display: inline-block;}

Answer №1

My solution to the problem:

<div class="rtl_div">
  <p>
    שלום1 English Words 9000 עולם2
  </p>
  <div class="flexy">
    <span>שלום1</span>
    <span>English Words</span>
    <span>9000</span>
    <span>עולם2</span>
  </div>
</div>

<br><br><br><br>
<div style="direction: rtl">
  Expected: <br>
  <image src="https://i.imgur.com/Zj3NYHo.png"></image>
</div>

Here is the CSS code I used:

.rtl_div{
  direction: rtl;  /* Must stay right to left */
}
.flexy{
  width: auto;
  height: auto;
  display: flex;
  color: red;
  font-size: 4vw;
  padding-right: 5%;
}
.flexy > span{
  margin-left: 3.5%;
}

You can view my solution on jsfiddle : https://jsfiddle.net/rz83e45s/5/

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

How can we improve our vertical division method?

Looking for a more efficient way to create a vertical divider between two divs. I want the divider to be centered between the "why choose" and "gallery" sections. Here is an example of what I'm trying to achieve. I've attempted the following co ...

Is there a way to transform a stream fetched from an S3 bucket into a JPEG image for display on my React frontend?

I've been grappling with a frustrating issue that seems to have solutions scattered all over the internet. Despite spending two full days trying to crack it, I just can't seem to find the right answer. Here's the crux of my problem: I hav ...

Is the Android Webview causing input boxes to double up?

Looking to develop an Android application that utilizes a webview for users to input their username/password, but encountering a strange issue where tapping on the input boxes creates duplicates (as shown in the image below). I have implemented the iScroll ...

"The issue lies in the JSON Array failing to display accurate content when the link is

I have implemented a functionality to bring in JSON data using Ajax & Jquery. The loaded data consists of various objects including: ID, TITLE, PERMALINK, CONTENT, ETC.(The rest is not important) My goal is to display each CONTENT object separately base ...

Creating a perfectly centered square canvas on your screen

In the game I'm developing, I need to position a canvas at the center of the screen. The canvas should have equal width and height, covering the entire screen without overflowing, essentially creating a square shape. Is there a way to achieve this us ...

Creating a versatile button that adjusts seamlessly across different screen sizes, from smartphones to larger

I need assistance with a straightforward task - creating a button that remains centered at all times. What would be the most effective method to achieve this, and is it possible to do so easily? Currently, I have managed to create a blue button; however, ...

How can you modify the HTML tags before Bootstrap overrides them?

Imagine having a code snippet like this: <style> #container ul li{ font-size:50px;} .myclass1 ul li{ font-size: 20px;} </style> <div id="container"> <ul> <li> <div class="myclass1"> ...

Creating an insert query in Node.js with frontend HTML and connecting it to a PostgreSQL database is a crucial task in web

I am new to working with Node.js, PostgreSQL. Currently, I am tackling the login form code and facing several issues related to the POST method. I am using HTML, Node.js, and PostgreSQL for this project. Please assist me with solving these problems by revi ...

Using CSS to place my logo within the navigation bar

Currently, I am struggling to find tutorials that can assist me in aligning the responsive navigation bar with the logo. As a newcomer to HTML & CSS and website creation, I would greatly appreciate any guidance on positioning it correctly. Additionally, co ...

Create a smooth transition: How to make a hidden button appear after a function finishes in JavaScript

I am completely new to the world of JavaScript, HTML, and CSS, so I'm feeling a bit lost on how to proceed with this task. My goal is to create a script that will initially display some text through a specific function. Once that text has been displa ...

Having trouble locating the text box using Selenium in Java. Xpath and CSS selectors are not working

I'm currently attempting to locate the textbox in the HTML snippet below using chromedriver ...

Alter the orientation of the current CSS shadow

Looking to modify the direction of a CSS shadow without adjusting the color or strength? box-shadow:green 0 1px 3px; I attempted to change the shadow direction only with the following code: box-shadow:inherit 2px 0 inherit; Unfortunately, this approach ...

Position the image to the right side of the Bootstrap Card

When working within a Bootstrap Card, I am trying to position the image to the right of the title and text, but it currently appears below them. How can I make the image align all the way to the right of the screen, next to the title and text? HTML: <d ...

A method for calculating the product of two selected numbers and then adding them together

I am currently working on a form that includes two select options; one for logo design and another for letterhead design. Users should be able to choose the quantity of each design, or both if they wish. For example, a user could select 2 logo designs and ...

I'm encountering an issue where Bulma is taking precedence over the CSS of my Vue3

In my Vue CLI 3 project, I'm utilizing Bulma and have included the import in the 'index.js' file like so: import { createApp } from 'vue' import App from './App.vue' import router from './router' require('@ ...

Can you provide guidance on how to label the y and x axis for Chartkick gem?

Is it possible for users to add labels to the x and y axes in Chartkick? Example Code: <%= line_chart Product.group("purchased").maximum(:price) %> ...

Improving Java Performance by frequently replacing one String with another

Currently, I am developing an HttpServlet extension (plugin) for a CMS that is responsible for filtering the HTML response. Within my method filterResponse, I retrieve the requested text/html as a String, which is one of three parameters. The main task a ...

What could be causing the mat-radio button in one card to toggle all other cards as well?

Within my home.component.html file, you will find the following code: <div class="grid grid-cols-5 gap-4 pt-10"> <div *ngFor="let card of cards" class=""> <div *ngIf="card==null;then nil else notnil&q ...

Unexpected results with mix-blend-mode difference

I am struggling with making a black text element overlap a black div while ensuring that the overlapping part of the text appears white. I attempted to use the mix-blend-mode property, but it does not seem to be working as expected. Why is this happening? ...

Looking for a prerequisite for running this script?

Seeking assistance from a skilled Javascript expert. I specialize in template development and utilize a specific script to display my footer link in all the free templates I create. If someone attempts to remove the footer link, their site will be redirec ...