• Register


If you want to center a list in HTML then you need to follow the given code example, just use some CSS properties to center a list

Approach:
In this problem, we will use CSS property for center list items in a webpage so before using CSS properties we need to know all about these CSS properties and its values:-

text-align : 
It is a CSS property and allow to center text or list in a webpage
it have three value ;

  • right – it’s used to display list in right side
  • left –  it’s used to display list items on the left side
  • center – it’s used to center list items

And here, we’re going to use the last one and we will also use the ordered and unordered list here.

display:

 It is allowed to set a width and height on the element.

Code:

<!DOCTYPE html>
<html>
<head>
	<title>Center List</title>
	
<!-- Internal CSS -->
	<style>

div{
	text-align: center;
}
ul{
	display: inline-block;
}

	</style>
</head>
<body>
	<div>
		<h3>What is the full form of FAANG?</h3>
		<ul>
			<li>Facebook</li>
			<li>Amazon</li>
			<li>Apple</li>
			<li>Netflix</li>
			<li>Google</li>
		</ul>
	</div>
</body>
</html>

Here, you will see after using CSS property value the HTML list is centered

110 points
3