In CSS, list items are typically displayed as block elements, meaning they span the full width of their container. However, you may want your list items to appear horizontally in a row. To achieve this, follow these steps:
1. Implement display: inline; on List Items
To make list items display inline, you need to apply the display: inline; property to them. However, directly applying this property to the
#ul_top_hypers li { display: inline; }
2. Adjust Parent Container (Optional)
In the provided code, the parent container (#div_top_hypers) also has display: inline; applied. While this is not necessary for the horizontal display of list items, it can prevent unwanted behavior in some cases.
Example
The following code snippet demonstrates the implementation of these steps:
#div_top_hypers { background-color:#eeeeee; } #ul_top_hypers li { display: inline; }
<div>
By following these steps, you can easily make your list items appear in a horizontal row using CSS.
The above is the detailed content of How to Make an Unordered List Display Horizontally in CSS?. For more information, please follow other related articles on the PHP Chinese website!