Inconsistent heights of inline lists compared to wrapped text

Hey there! I'm having an issue with my inline list when the text in the anchor wraps onto a new line. I tried using line-height: 0;, but it's causing some problems with the text display. Any suggestions on how to keep everything on the same line?

Check out the code below:

#communityBoardsLinks{ margin: 10px 0 20px 0; list-style: none; padding: 0;}
#communityBoardsLinks li{
  display: inline-block;
  background-color: black;
}
#communityBoardsLinks li a{
  font-family: sans-serif;
  display: block;
  color: white;
  font-weight: bold;
  font-size: 24px;
  width: 96px;
  height: 96px;
  padding: 10px;
  text-decoration: none;
}
#communityBoardsLinks li a:hover{ color: red;}
#communityBoardsLinks li:last-child{ width: 115px;}

#wrapperMan{ width: 715px;}
<div id="wrapperMan">
<ul id="communityBoardsLinks>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Long Link</a></li>
<li><a href="#">Long Link</a></li>
<li><a href="#">Long Link</a></li>

</ul>

Answer №1

To align the content at the top of #communityBoardsLinks li, add the CSS property vertical-align: top;.

#communityBoardsLinks{ margin: 10px 0 20px 0; list-style: none; padding: 0;}
#communityBoardsLinks li{
  display: inline-block;
  background-color: black;
  vertical-align: top;
}
#communityBoardsLinks li a{
  font-family: sans-serif;
  display: block;
  color: white;
  font-weight: bold;
  font-size: 24px;
  width: 96px;
  height: 96px;
  padding: 10px;
  text-decoration: none;
}
#communityBoardsLinks li a:hover{ color: red;}
#communityBoardsLinks li:last-child{ width: 115px;}

#wrapperMan{ width: 715px;}
<div id="wrapperMan">
<ul id="communityBoardsLinks">
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Long Link</a></li>
<li><a href="#">Long Link</a></li>
<li><a href="#">Long Link</a></li>
</ul>
</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

Ensure that the modal remains open in the event of a triggered keydown action, preventing it from automatically closing

I am currently toggling the visibility of some modals by adjusting their CSS properties. I would like them to remain displayed until there is no user interaction for a period of 3 seconds. Is there a way to achieve this using JavaScript? Preferably with Vu ...

Show specific content based on which button is selected in HTML

I am working on a project where I have three buttons in HTML - orders, products, and supplier. The goal is to display different content based on which button the user clicks: orders, products, or supplier information. function showData(parameter){ i ...

What steps should I take to resolve the issues in my Email Contact Form PHP?

I am new to PHP coding and struggling with my Email contact form. I found the email form on a website called and made some text changes but not the code. Here's the HTML code snippet from my file: <form name="contactform" method="post" action="s ...

How to horizontally center an element using HTML and CSS

I am encountering an issue while trying to create a navigation bar or header. The problem lies in centering an h1 element. Here is the HTML code I am using: body { margin: 0; padding: 0; } header { display: flex; justify-content: space-between; ...

"Is there a way to transfer a value from one list box to another without needing to refresh the page, by utilizing AJAX,

Is there a way to automatically load Related Course levels in the Course Level Listbox when selecting a Course from the Course list? <script type="text/javascript" src="js/jquery.js"></script> <div>Course:<select name="course_id" id= ...

Designing an image to adjust to different screen sizes while maintaining its specified dimensions

I'm currently retrieving pictures from Bing, but unfortunately you have to specify the height/width of the image in the URL. I want the map image to always be aligned with the table on the left, regardless of the desktop screen size or the number of r ...

Insert a colon after a designated amount of characters

One interesting feature on my webpage is the "Search Box". In this case, the value stored in the database is 00:12:34:56 However, an issue arises when searching for 00123456 as it does not return the correct result. Is there a way to automatically insert ...

What is the best way to ensure that text only displays up to five lines and fully collapses using CSS or javascript/jquery?

Hello everyone, I have come across an issue. English is not my strong suit, but I will do my best to explain it thoroughly. The problem at hand is a design requirement in the draft that specifies showing up to five lines of text. If the text exceeds this ...

JavaScript: Modifying the Style of a :lang Selector

Currently, I am working on creating a basic multilingual static website using only HTML5, CSS3, and vanilla JavaScript. The structure of the HTML looks something like this: <html> <head> <title>WEBSITE</title> ...

Troubleshooting: Font-Awesome Symbols are not Showing up

I am facing an issue where the font-awesome social media icons are not displaying on any browser. However, all other icons appear to be working without any problems. I have attached a screenshot of the page open in Mozilla with inspect element (you can ...

The cursor remains positioned below the video within the designated div

I'm currently facing an issue in a project where the cursor div I created stays underneath the video element. No matter what I do, I can't seem to bring it to the front. Even setting a z-index on the video tag hasn't helped. Can someone plea ...

Guidelines for comparing two distinct dates using jQuery

const currentDate = $("#date").text(); // the current date is set as a variable 01/06/2017 // Another date is declared as a variable let startDate = '01 / 06 / 2017'; if (currentDate == startDate) {} if (currentDate < startDate) {} <script ...

What is the best way to split two divs in this manner?

Is there a way to split two divs like this in such a manner using TailwindCSS? Alternatively, what would be the CSS code for dividing these two divs? I am struggling with this concept and cannot wrap my head around how it can possibly be achieved. ...

Make sure to validate a form when submitting from an external source rather than through an HTML

In my form, there are various input fields (some acting as inputs even if they're not). Each field is validated upon submission by angular validation and html attributes like required, ng-maxlength, minlength, etc. Now, we want to implement a keyboar ...

table with flexible cell width and fixed table width

I've been troubleshooting this issue for days, but I just can't seem to find a solution! The problem lies within a table used on a webpage. If I don't specify table-layout, I can make one cell width dynamic, but I lose the ability to set &a ...

What is the best way to align an image and text in a grid?

As a novice in the world of HTML and CSS, I am attempting to master the 1fr 1fr grid layout for my "welcome" section. My goal is to have an image on the left side and text on the right side. However, when I switch to Responsive mode in Inspect, my grid col ...

`I noticed that the CSS appears differently when viewed in Mozilla compared to Chrome``

Why do the images with the same CSS property appear different in Chrome and Mozilla? I want them all to float left with equal margins between them, covering the complete area horizontally despite having varying image widths. I'm unsure why there is a ...

Is it possible to use CSS to target the nth-child while also excluding certain elements with

How can I create a clear break after visible div elements using pure CSS? Since there isn't a :visible selector in CSS, I attempted to assign a hidden class to the div elements that should be hidden. .box.hidden { background: red; } .box:not(.hid ...

Elevate the value of a particular element's variable through the execution of a function

By using a for loop, I was able to generate a variable number of divs that change their background color individually when hovered over with the mouse. Now, I want to implement a function that will decrease the brightness of each div by 10% every time it i ...

left-floating div

I am currently working on designing a page that requires multiple columns to be displayed. The columns should float left and never appear stacked on top of each other. Ideally, I would like the columns to extend beyond the screen without a scrollbar, makin ...