+ 3

Which tag is used to align image to center

Please help me

19th Jun 2019, 5:07 PM
Nathnael Desalegn
Nathnael Desalegn - avatar
10 Réponses
+ 7
Cbr✔[exams] LOL... I like your quote: "Well let's enjoy the moment since the center tag is still supported..." 😂🤣 For those interested in why legacy tags like <center>, <b>, <font>, <i>, <u>, and others are slated to be deprecated, it's because these tags are meant to describe formatting, which is a presentation concern. One of the objectives of HTML5 was to implement a separation of concerns between content and design. This allows for the HTML to focus on content as data, such that changes to design should not require changes to document elements. Therefore, if an element needed to be changed from a center layout to right aligned, the change would only require an update to CSS. The reason these are still supported today is to give existing websites ample time to remove these tags before browsers drop support for them altogether. Therefore, it might not be a good idea to use these tags on anything in a production release of a website. I hope this explanation is helpful.
21st Jun 2019, 12:56 AM
David Carroll
David Carroll - avatar
+ 6
Ayush Sinha I would also add that the align attribute in an HTML element is deprecated with HTML5.
21st Jun 2019, 5:38 AM
David Carroll
David Carroll - avatar
+ 5
20th Jun 2019, 7:09 PM
Asmit joy
Asmit joy - avatar
+ 5
Cbr✔[exams] Your CSS alternative using absolute positioning is good if the image doesn't need to be relative to other elements. Once absolute positioning is introduced, the approach to styling those elements are applied to a completely separate context than those using relative positioning. Coordinating the alignment between multiple contexts can get a bit tricky as the page gets more complex. I try to avoid absolute positioning to spare myself the many painful hours that typically follows when attempting to apply the simplest change causing a ripple effect of problems. 😉 I recommend keeping relative positioning by setting the left and right margins to auto. The element should also be set to block, if it's inline. Ex: img {  display: block; margin-left: auto; margin-right: auto; }
21st Jun 2019, 1:19 AM
David Carroll
David Carroll - avatar
19th Jun 2019, 5:47 PM
Bug Slayer
+ 1
https://www.sololearn.com/discuss/1837183/?ref=app
19th Jun 2019, 6:57 PM
Giorgos Mariettakis
Giorgos Mariettakis - avatar
+ 1
David Carroll most informational as always. Thank you for laying out those details.
21st Jun 2019, 1:18 AM
SQrL
SQrL - avatar
0
Cbr✔[exams] center was a tag , its not a w3c recommendation. however many browsers support this tag, Chrome is one of them it could be removed any time from browser support
20th Jun 2019, 3:55 AM
Bug Slayer