+ 3
I can not align the block
Хочу выровнять по центру страницы отдельно взятый блок. Но через <div align="center" class="section"> выравнивается непосредственно текст в блоке, а не сам блок. Что делать? I want to align an individual block on the center of the page. But the <div align = "center" class = "section"> aligns the text directly in the block, not the block itself. What to do?
5 Respostas
+ 11
<!--have you tried using margin-left: auto; margin-right: auto; -->
<!--@Vengat
let's assume he closed the div... -->
<body>
<div id="center_align"></div>
<style>
div{
margin-left: auto;
margin-right: auto;
background-color: rebeccapurple;
width: 200px;
height:400px;
}
</style>
</body>
+ 5
Where is your closing tag?
Blocks without closing tags won't align
+ 2
'align' attribute is deprecated in Html5, and should be auto-corrected as 'text-align' css property wich apply on element content...
<div> is container of type block, so it take the whole width available: centering it as is have no really sense (by the way, it's still and always centered)...
Anyway, you can center a block by different ways... I could enumerate some, but it would be more efficient if you would provide your whole code to help you with a good suited solution ^^
+ 1
I think, that problem not this.
I have closing tag.
0
Lord Krishna, instead of 2 margin rules, you could shorten to a single rule :
div {
width: 800px;
border : 1px solid gray ;
margin: 0 auto;
}