How to create texture background using CSS ?
Last Updated :
17 Mar, 2023
Introduction: We can use CSS property to texture the background of the web page by using an image editor to cut out a portion of the background. Apply CSS background-repeat property to make the small image fill the area where it is used. CSS provides many styling properties of the background including coloring the background, background images, etc. Background properties. are background color, background image, background position, and background attachment.
The approach of texturing the background: There are some steps for texturing the background using CSS with examples and explanations.
Create an html file using HTML tags.
html
<html>
<head>
<title>
Texture Background
Using CSS
</title>
</head>
<body></body>
</html>
Choose the texture color that we want to set in the Background. Save the texture color in image format like(.png, .jpg etc)
Suppose we want to set the background of this web page using internal sheet CSS. So write the following code in head section.
CSS
<style>
body {
background-image: url("BG.jpg");
background-repeat: repeat/no-repeat;
background-size: 1600px 840px:
}
</style>
Example:
html
<!DOCTYPE>
<html>
<head>
<title>
Texture Background using CSS
</title>
<style>
body {
background-image: url(
"https://write.geeksforgeeks.org/wp-content/uploads/backgroundimage-1.png");
background-repeat: no-repeapt;
}
</style>
</head>
<body>
<h1>
This is our texture
background
</h1>
</body>
</html>
Explanation: In this code, we are placing the image in the background through background-image:url("backgroundimage-1.png"); in the form of .jpg. It can be in .png also.Here, we are not repeating the image in the background so, the image shown only one time in the background, background-repeat:no-repeapt; this syntax means image is not repeating. These all commands are written in <style> tag using CSS.
Output: 
Example 2: To create a textured background using CSS, we can use a combination of CSS background properties and an image.
Syntax:
body {
background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.5));
background-repeat: repeat;
background-size: 200px;
background-position: center;
background-color: #b5dc89;
}
HTML
<!DOCTYPE html>
<html>
<head>
<title>Textured Background Example</title>
<style>
body {
background: linear-gradient(to bottom,
rgba(0, 0, 0, 0),
rgba(0, 0, 0, 0.5));
background-repeat: repeat;
background-size: 200px;
background-position: center;
background-color: #b5dc89;
}
.content {
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<h1>GeeksforGeeks !</h1>
<h1>Textured Background Example</h1>
<p>
This is an example of a textured background
created with CSS.
</p>
</div>
</body>
</html>
Description: In this example, we're using the same overlaying of a linear gradient from transparent to semi-transparent black to give it a more subtle effect. We've set the background-size to 200px to make the texture larger, background-position to center the texture, and background-color to light green to ensure the texture is visible even if the image doesn't load.
Output:
Similar Reads
How to Create Wave Background using CSS? A wave background is a design element having wavy patterns or shapes used to add movement in the web pages. The :before pseudo-element can be used to create a wavy background by applying it to an element and using CSS properties like clip-path to create wave shapes.Using :before pseudo-elementTo cre
2 min read
How to create linear gradient background using CSS ? In CSS, we can use the background-color property to set the background color of an element to a specific color. Sometimes we want to add more styling to the element when setting the background color by using the linear-gradient property. CSS linear-gradient property lets you display smooth transitio
4 min read
How to use Text as Background using CSS? Using text as a background in CSS means creating a visual effect where large text is placed behind content, often appearing as a decorative or watermark-like element. This effect can be achieved by positioning, opacity adjustments, and layering techniques with CSS.Here we have some common methods to
3 min read
How to blur background image using CSS ? CSS (Cascading Style Sheets) is a language used to describe the appearance and formatting of a document written in HTML. In this article, we will learn how to blur background images using CSS, along with basic implementation examples. Blurring Background Images with CSSTo blur a background image usi
3 min read
How to create Chess pattern background using HTML and CSS ? Chess patterns are simply certain tactical positions that regularly occur in games. It can be easily designed by using the pseudo selector of CSS. This type of pattern can be used to create confusing illusions. Preview: Approach: Create a centered container for the chessboard with a fixed size and b
2 min read
How to Create Custom Banner Background Using CSS ? A Custom Banner Background in CSS refers to a specifically designed or styled background for a webpage banner, often using unique images, colors, gradients, or patterns. It enhances visual appeal and branding by adjusting properties like background-size, and background-position for a tailored look.A
2 min read
How to Rotate Container Background Image using CSS ? Rotating a container's background image using CSS involves applying the transform: rotate() property to the container element. This rotates the entire element at a specified angle, including its background image, creating a dynamic, rotating visual effect on the web page's design.Approach: Using tra
2 min read
Create a Galaxy Background using HTML/CSS In this article, we will see how to create the galaxy background using the HTML & CSS, along with knowing the basic CSS properties used & will understand it through the example. A galaxy background means a small bunch of circles having different sizes with different shades and a dark backgro
3 min read
How to create a Full-Page Background with CSS ? To create a full-page background with CSS, set the body's height to `100vh` to cover the viewport, and add a background image using `background-image`. Ensure the image fills the entire viewport without distortion by setting 'background-size: cover'. Optionally, adjust 'background-position' and 'bac
2 min read
How to create and style border using CSS ? The border property is used to create a border around an element and defines how it should look. There are three properties of the border. border-colorborder-widthborder-style border-style property: This defines how the border should look like. It can be solid, dashed, offset, etc. The following val
4 min read