I need to adjust the alignment of the text within my list item that includes a time element

I am struggling with aligning my elements vertically downward as the text following the "-" appears disorganized.

I attempted to enclose the time tags within div elements and align them so that they evenly occupy space, but this approach did not work. Instead, it caused the li elements to be separated into different blocks.

#time-line{
    max-width: 700px;
    margin:0 auto 0 auto;
    font-family:Georgia, 'Times New Roman', Times, serif;
}
ul{
    line-height: 2em;
}
.dates{
    font-weight:bold;
}
 <section id="time-line">
            <h2>Follow His Timeline.</h2>
<!--List Element I want to align-->
        
    <ul><!--when the code displays the hyphens are not all vertically on a straight line I have tried adding <div> to them and give them a specific with but in does not display them in line it breaks the contain-->
            <li><time datetime="1901-09-21" class="dates">Sep 21, 1901 - </time></span> Knrumah is born in Ghana.</li>
            <li><time datetime="1935-08-07" class="dates">Aug 07, 1935 - </time>Moved to America and goes to Lincoln University.</li>
            <li><time datetime="1939-05-22" class="dates">May 22, 1939 - </time>Graduation from University</li>
            <li><time datetime="1945-09-09" class="dates">Sep 09, 1945 - </time>Moves to London and he helped to organize the Fifth Pan-African Congress.</li>
            <li><time datetime="1947-05-11" class="dates">May 11, 1947 - </time>Wrote his first book, <cite id="book-title">"Towards Colonial Freedom"</cite></li>

Answer №1

One way to improve the appearance of the timeline is by adding width to the .dates element and changing its display property. Inline elements do not respond well to width adjustments, so it's best to use inline-block instead. I also suggest moving the character '-' outside of the <time> tag for better alignment. To enhance the aesthetic further, wrap the content in a <span> tag and add some margin for spacing.

#time-line{
    max-width: 700px;
    margin:0 auto 0 auto;
    font-family:Georgia, 'Times New Roman', Times, serif;
}
ul{
    line-height: 2em;
}
.dates{
    font-weight:bold;
    width: 110px;
    display: inline-block;
}
 <section id="time-line">
            <h2>Follow His Timeline.</h2>
<!--List Element I want to align-->
        
    <ul><!--when the code displays the hyphens are not all vertically on a straight line I have tried adding <div> to them and give them a specific with but in does not display them in line it breaks the contain-->
            <li><time datetime="1901-09-21" class="dates">Sep 21, 1901</time> -  Knrumah is born in Ghana.</li>
            <li><time datetime="1935-08-07" class="dates">Aug 07, 1935</time> - Moved to America and goes to Lincoln University.</li>
            <li><time datetime="1939-05-22" class="dates">May 22, 1939</time> - Graduation from University</li>
            <li><time datetime="1945-09-09" class="dates">Sep 09, 1945</time> - Moves to London and he helped to organize the Fifth Pan-African Congress.</li>
            <li><time datetime="1947-05-11" class="dates">May 11, 1947</time> - Wrote his first book, <cite id="book-title">"Towards Colonial Freedom"</cite></li>

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

What is causing Angular to consistently display the first object in the array on the child view, while the child .ts file correctly prints information from a different object?

Once a card of any object is clicked, the information of that specific object will be printed to the console. However, the child view will only display the details of the first object in the array it retrieves from. All pages are included below. A visual e ...

Opt for CSS (or JavaScript) over SMIL for better styling and animation control

I recently noticed an alert in my Chrome console that SVG's SMIL animations are being deprecated and will soon be removed. The message suggested using CSS or Web animations instead. Since I want to transition from SMIL to CSS animations, there are a ...

Styling for jQuery mobile panels disappears when used on multiple pages

Currently, I am working on developing a mobile application for PhoneGap using jQuery Mobile. The app consists of multiple pages within the same HTML document. I have configured it so that all pages share the same panel, but I am facing an issue with the st ...

The website displays perfectly in Atom, however, it is not functional in any web browser

My website is currently in the development phase, and I'm experiencing issues with certain div elements not positioning correctly once the site goes live. Specifically, the "Follow Us" tab at the bottom of the site, among other divs, has been affecte ...

Adjusting the content of mat-cards to fill in blank spaces

I have encountered an issue with the alignment in a list using mat-card. Here is my current layout: https://i.stack.imgur.com/VKSw4.jpg Here is the desired layout: https://i.stack.imgur.com/8jsiX.jpg The problem arises when the size of content inside a ...

What is the best way to send an array element to a function?

In my PHP code, I am fetching data from a database and encoding it in JSON to be called by an AJAX request. while ($row = mysqli_fetch_assoc($empRecords)) { $data[] = array( "level"=>$whatTeam($row['level&a ...

How can I expand the notification pop-up in R Shiny?

I'm trying to figure out how to expand the notifications in R Shiny because right now they are cutting off longer error messages. Any suggestions? library(shiny) ui <- fluidPage( actionButton("test", "Test") ) server <- f ...

Styling: Ensuring my sidebar does not overlap with my main content on the webpage

Currently, I am working on arranging my sidebar and map so that they are displayed side by side instead of the sidebar appearing on top of the map (as shown in the image). I'm seeking advice on how to achieve this layout using CSS because I have been ...

Send the value of an li element using AJAX when clicked back to the original page

I'm currently working on passing the data-value of the < li > element that I clicked on to PHP within the same page. My approach involves using AJAX to send the data to PHP for querying purposes. While it seems like the AJAX request is functioni ...

What's the best way to align text at the center of this DIV?

I recently created a small offline website with a header that includes a logo, navigation bar, and notification bar. While I managed to align everything as intended, I encountered an issue with the text alignment within the notification bar (header-alert). ...

How to rename a class of an image tag using jQuery

I need to update the class name in my image tag <img src="img/nex2.jpeg" class="name"> When hovering over with jquery, I want to add a new class to it. After hovering, the tag should appear as follows: <img src="img/nex2.jpeg" class="name seco ...

Try using Bootstrap 4 Carousel columns instead of the traditional carousel-item

Is it possible to use Bootstrap to display grid columns or rows within a Carousel instead of carousel-items? The concept involves having intricate grid column structures that rotate like carousel-items. For instance, if we have the following grid: <div ...

What is the best way to position the label above the input text in a Material UI TextField component with a Start Adornment?

Struggling to figure out the right Material UI CSS class to style a reusable TextField component? You're not alone. Despite tinkering with InputLabelProps (specifically the shrink class), I can't seem to get it right. Here's the code snippet ...

Rails : CSS/JavaScript functioning perfectly on local server, facing issues on Heroku deployment

My Rails website features various CSS animation effects and JavaScript elements. While these transitions function smoothly on my local environment, they do not work properly on Heroku. Examining the Heroku logs: 2013-09-17T17:13:36.081145+00:00 app[web.1 ...

Check for the presence of a horizontal scrollbar on the page for both computer and mobile devices

Is there a way to determine if a web page has a horizontal scrollbar using jQuery or pure JavaScript? I need this information to dynamically change the css of another element. I initially tried function isHorizontalScrollbarEnabled() { return $(docum ...

The presence of element a within the element ul is not permitted in this particular scenario. Additional errors from this section will not be displayed

Having trouble with this code snippet: <nav role="navigation"> <div id="menuToggle"> <input type="checkbox"/> <span></span> <span></span> <span></span> ...

The JavaScript function modifies the value stored in the local storage

I'm in the process of developing a website that requires updating the value of my local storage when certain JavaScript functions are executed. Currently, I have this code snippet: localStorage.setItem('colorvar', '#EBDBC2'); I&ap ...

Experiencing trouble with setting values in JavaScript?

I have my code set up to display numbers 170 and 122 using Javascript, but I'm not seeing the expected output. <!DOCTYPE html> <html> <body> <button onclick="UidToPost()">Get It</button> <script> ...

Ways to show text on top of an image using CSS

Seeking help! I'm attempting to overlay some text on top of an image, here's the link: http://jsfiddle.net/5AUMA/31/ The challenge is aligning this text to the bottom part of the image. I've tried using this CSS: .head_img p { position ...

Is it necessary to add a line break after a span element generated by react, next, or bootstrap

There is a strange issue plaguing my code - I'm enclosing some text in a span tag and it's causing an unexpected line break. It's unclear whether React.js, Next.js, or Bootstrap is the culprit, but I can't seem to get rid of the pesky l ...