HTML Dog
Skip to navigation

Repeating background images

Using the background-repeat property.

HTML

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>background-repeat</title>
	<style>
		body {
			font: 14px courier;
			background: #fff;
			color: #000;
			margin: 0;
			padding: 10px;
		}
	
		p {
			background-color: #ccc;
			background-image: url("/examples/images/opacityBg.gif");
			margin: 10px;
			width: 300px;
			height: 300px;
			float: left;
			text-align: center;
		}
		code {
			background: white;
			padding: 0 15px 2px;
		}

		#p1 {
			background-repeat: repeat;
		}
		#p2 {
			background-repeat: no-repeat;
		}
		#p3 {
			background-repeat: repeat-x;
		}
		#p4 {
			background-repeat: repeat-y;
		}
		#p5 {
			background-repeat: space;
		}
		#p6 {
			background-repeat: round;
		}

		#borderCollie a {
			display: block;
			height: 300px;
			background: white url("http://www.htmldog.com//badge1.gif") center no-repeat;
			text-indent: -999em;
		}	
	</style>
</head>
<body>
	<p id="p1"><code>background-repeat: repeat;</code></p>
	<p id="p2"><code>background-repeat: no-repeat;</code></p>
	<p id="p3"><code>background-repeat: repeat-x;</code></p>
	<p id="p4"><code>background-repeat: repeat-y;</code></p>
	<p id="p5"><code>background-repeat: space;</code></p>
	<p id="p6"><code>background-repeat: round;</code></p>

	<!-- Link back to HTML Dog: -->
	<p id="borderCollie"><a href="http://www.htmldog.com/examples/"><img src="http://www.htmldog.com/badge1.gif" alt="HTML Dog"></a></p>
</body>
</html>

Output

View original