
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How to set all the background properties in one declaration with JavaScript DOM?
To set the background in JavaScript, use the background property. It allows you to set the background color, image, position, etc.
Example
You can try to run the following code to learn how to set all the background properties in a single declaration with JavaScript.
<!DOCTYPE html> <html> <body> <button onclick="display()">Click to Set background</button> <script> function display() { document.body.style.background = "url('https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg') repeat right top"; } </script> </body> </html>
- Related Articles
- How to set all the border bottom properties in one declaration in JavaScript DOM?
- How to set all the outline properties in one declaration with JavaScript?
- How to set all the border left properties in one declaration with JavaScript?
- How to set all the border right properties in one declaration with JavaScript?
- How to set all the border top properties in one declaration with JavaScript?
- How to set all outline properties in a single declaration with JavaScript?
- Set all the background image properties in one section with CSS
- Set all the top border properties in one declaration using CSS
- How to set the CSS margin properties in one declaration?
- How to set listStyleImage, listStylePosition, and listStyleType in one declaration with JavaScript?
- How to set a background image to be fixed with JavaScript DOM?
- How to set border width, border style, and border color in one declaration with JavaScript?
- How to set fontStyle, fontVariant, fontWeight, fontSize, lineHeight, and fontFamily in one declaration with JavaScript?
- How to set all the four border radius properties at once with JavaScript?
- How to set the starting position of a background image in JavaScript DOM?

Advertisements