How do i center the heading in my form heading?

╄→гoц情女王★ 提交于 2019-12-04 04:10:09

问题


I am using the center tag to center a heading in my form, "Please register your details". It works perfectly like I want it to but it fails the validation. Does any one else know what I could use?

<form method = "post" action = "mailto:info@ncirl.ie">

<fieldset>

<legend><center><b>Please Register Your Details</b></center></legend>

回答1:


Instead of using <center> which will force your design to be centered forever, you should deal with it in CSS:

form legend { text-align:center;font-weight:bold; }



回答2:


Put your heading into a div and text-align:center it. If I am not wrong center has been deprecated. All this stuff should sit in your css.

<div style="text-align:center">
  Please register your details
</div>



回答3:


While the width of the label element by default is 100%, the display is still inline. Without using the block display AND specifying a width: margin:0 auto; will NOT work.

The only correct use for this instance is:

<legend style="text-align:center;">Please Register Your Details</legend>

Setting a width for this would be unwise, as the physical font width can vary between browsers, and "over compensating" the width will result in offsetting the text from the center.



来源:https://stackoverflow.com/questions/20436749/how-do-i-center-the-heading-in-my-form-heading

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!