Two text in same line html

How can I position two text blocks on the same line, one to the left and the one to the right, without using floats?

Like this:

Bla bla                   5
Whatever                 25
Boo                      12

Each line is a list item -

  • asked Jan 11, 2011 at 1:05

    1

    You have numbers in your example, which indicates to me that you may be showing tabular data. If that's the case, use a table. Easy!

    If that's not the case, use spans with a set width:

    .label {
         display: inline-block;
         width: 200px; // or whatever
    }
    

    and:

    • Blah blah 5
    • Stuff 25

    answered Jan 11, 2011 at 2:27

    keithjgrantkeithjgrant

    12.1k5 gold badges51 silver badges87 bronze badges

    4

    You could use tables. Also, you could use absolute positioning and setting the same value for top and bottom to each ul object

    answered Jan 11, 2011 at 1:39

    SuperIRisSuperIRis

    4235 silver badges9 bronze badges

    you can see a working example here

    ul {
        list-style-type:none;
    }
    li span {
        display:inline-block;
        width:100px;
    }
    
    
    • Bla Bla 5
    • Whatever 25

    answered Jan 11, 2011 at 1:56

    Omer BokhariOmer Bokhari

    55.2k12 gold badges43 silver badges55 bronze badges

    I know this is an old one, but it would seem like the most semantically correct option here would be to use DL, DT and DT instead of LI.

    Bla bla
    5
    Whatever
    25
    Boo
    12

    Then you would style it like this:

    dl {
        margin: 0;
    }
    
    dt {
        clear: left;
        float: left;
        padding: 0 0 2px;
        font-weight: bold;
    }
    
    dd {
        float: left;
        margin-left: 10px;
        padding: 0 0 2px;
    }
    

    I know you stipulated no floats, but that is the way to get the job done.

    answered Feb 10, 2012 at 0:52

    Here is a very simple trick I used. It does use floats, but I think it still looks pretty nice:

    HTML:

    Chicken Craft

    Minecraft Server

    CSS:

    .title1 {
      text-align: left;
      color: #269CEB;
      margin-top: 0px;
      float: left;
      clear: both;
    }
    
    .title2 {
      text-align: left;
      color: #FF9D00;
    }
    

    answered May 29, 2013 at 0:37

    VanceVance

    111 bronze badge

    All elements can be displayed on one line best known for: setting whitespace properties to a parent element and having display in block.

    Table of contents
    • How Do I Put Two Text On The Same Line In Html?
    • How Do I Display Two Tags On The Same Line?
    • How Do I Align Text In One Line In Css?
    • How Do I Put Two Text On The Same Line In Css?
    • How Do I Put Text On The Same Line In A Div?
    • How Do I Separate Text In A Line In Html?
    • How Do I Have Two Lines On The Same Line In Html?
    • How Do I Keep Two Lines On The Same Line In Css?
    • How Do You Get Two Buttons On The Same Line?
    • Can We Align Text Using Css?
    • How Do I Fix Text Alignment In Css?

    How Do I Put Two Text On The Same Line In Html?

  • (2) Replace the first ‘p’ tag with only one; then add the following style attribute for a home style=“float: right;” $:1 0 /span>..hr (3).
  • How Do I Display Two Tags On The Same Line?

    In CSS styles, we can use the float property to place multiple div tags at once. Its optional properties leave, right, none(default value) indicate where the left div tag should float. The right one tells the left div tag to be passed to inherit.

    How Do I Align Text In One Line In Css?

  • With these text-align properties, an inline content is aligned using div style=”text-align: left;”> in a block, for example.
  • As an example, to show how inline content should be aligned vertically compared to sibling content, the vertical-alignment property is used.
  • How Do I Put Two Text On The Same Line In Css?

  • In this case, white-space property will be used to nowap on elements of the parent structure.
  • Ensure that each element’s block is inline in position.
  • How Do I Put Text On The Same Line In A Div?

    As a way to hold the text together in an element set, set the CSS for HTML / HTML *div> to match it. You may need both the overflow and the white space properties to wrap.

    How Do I Separate Text In A Line In Html?

    There is a break created in the HTML when the text return (carriage-return).

    How Do I Have Two Lines On The Same Line In Html?

    In order to make two divs in the same line with same width and style, give these two divisions space rather than an entire line. For both divs, the width is equal or less than their parent div whose floats cover these two divs, so that each div is floated as part of its parent div’s widths.

    How Do I Keep Two Lines On The Same Line In Css?

    “& ” should be left as a non-breaking space to separate two words when there is only one instance of them. The next time you want to keep the browser to keep it, just specify that.

    How Do You Get Two Buttons On The Same Line?

    Every button should have the data-inline=”true” attribute in its data column if it should sit side-by-side on the same line. As a result, the content will be styled so that the buttons are sized correctly and positioned at a particular level.

    Can We Align Text Using Css?

    If we are using an CSS checkbox, we need to define “center.” at the text-align property. With an easy example, let’s start with this. An example would be to say that your web page is text-only. To set this up, first take a look at the CSS universal selector (*) or typeselect body to determine all elements that need to be targeted.

    How Do I Fix Text Alignment In Css?

    Default value: left if direction is ltr, and right if direction is rtl
    JavaScript syntax: object.style.textAlign=”right” Try it

    How do I put two text on the same line in CSS?

    You can use a table :) If they're all inline elements, setting their display:inline; property should work.

    How do I align text in one line in HTML?

    To set text alignment in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML

    tag, with the CSS property text-align for the center, left and right alignment.

    How do I display two tags on the same line?

    To display multiple div tags in the same line, we can use the float property in CSS styles. The float property takes left, right,none(default value) and inherit as values. The value left indicates the div tag will be made to float on the left and right to float the div tag to the right.

    How do you put two things side by side in HTML?

    The most common way to place two divs side by side is by using inline-block css property. The inline-block property on the parent placed the two divs side by side and as this is inline-block the text-align feature worked here just like an inline element does.