
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to set the CSS margin properties in one declaration?
The margin property defines the space around an HTML element. It is possible to use negative values to overlap content. It specifies a shorthand property for setting the margin properties in one declaration.
Example
You can try to run the following code to set margins
<html> <head> </head> <body> <p style = "margin: 20px; border:2px solid yellow;"> All four margins will be 20px </p> <p style = "margin: 15px 4% -10px; border:2px solid red;"> Top margin will be 15px, left and right margin will be 4% of the total width of the document, bottom margin will be -10px </p> </body> </html>
- Related Articles
- Set all the top border properties in one declaration using CSS
- How to set all the outline properties in one declaration with JavaScript?
- CSS Margin Properties
- How to set all the background properties in one declaration with JavaScript DOM?
- 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 the border bottom properties in one declaration in JavaScript DOM?
- How to set all outline properties in a single declaration with JavaScript?
- Set all the background image properties in one section with CSS
- How to set listStyleImage, listStylePosition, and listStyleType in one declaration with JavaScript?
- Set the right margin of an element with CSS
- Set the top margin of an element with CSS
- 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?

Advertisements