Results 1 to 4 of 4

Thread: how can i centere block eliminate using css1?

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2019
    Posts
    44

    how can i centere block eliminate using css1?

    how can i centere block eliminate using css1?
    < advertising removed by moderator >

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,714

    Re: how can i centere block eliminate using css1?

    To center a block element using CSS1, you will need to follow the CSS, Level 1 - Horizontal Formatting of Block Elements guideline. Specifically:
    Otherwise, if both 'margin-left' and 'margin-right' are 'auto', they will be set to equal values. This will center the element inside its parent.
    Here is an example:
    HTML Code:
    <div></div>
    Code:
    div {
      border: 1px solid black;
      height: 250px;
      margin-left: auto;
      margin-right: auto;
      width: 250px;
    }
    Fiddle: Live Demo
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    Banned
    Join Date
    Jan 2021
    Location
    USA
    Posts
    25

    Re: how can i centere block eliminate using css1?

    To center block element with CSS1 we have to use the margin property. By setting the values of margin-left to auto and margin-right to auto and width to some explicit value: block level element will center itself.

  4. #4
    Member
    Join Date
    Jul 2019
    Location
    Ahmedabad
    Posts
    57

    Re: how can i centere block eliminate using css1?

    To center block element with CSS1 This is done by setting the properties margin-left and margin-right to auto and width to some explicit value:


    Here is an example
    HTML Code:
    <html>
    	<head>
    	<style type="text/css">
    		p{
    		 border:1px solid black;
    		  width: 220px; 
    		  margin-left: auto; 
    		  margin-right: auto
    		}
    	</style>
    	</head>
    	<body>
    	 <p> center block element</p>
    	</body>
    </html>
    Last edited by dday9; Mar 8th, 2021 at 09:40 AM.
    < advertising removed by moderator >

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width