Html 如何使用css将所有标签以粗体显示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35066871/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 18:52:49  来源:igfitidea点击:

how to put all labels in bold with css

htmlcssfontscolors

提问by David Benalal

how do I make all labels such as : first name, last name, etc in bold, by using header only? thank you

如何仅使用标题以粗体显示所有标签,例如:名字、姓氏等?谢谢你

 <form>
                <fieldset class="set1">
                    <legend class="set1">Music Lover's Personal information</legend>
                    First Name
                    <input type="text" name="firstname" value=""><br><br>
                    Family Name
                    <input type="text" name="lastname" value=""><br><br>
                    Gender:
                    <input type="radio" name="gender" value="Female">Female
                    <input type="radio" name="gender" value="male">Male<br><br>
                    What age category are you from?

回答by Jorge Fosela

I would wrap each label in a labeltag and then in CSS, with this code, you can get it:

我会将每个标签包装在一个label标签中,然后在 CSS 中,使用此代码,您可以得到它:

form label {font-weight:bold}

Hope this helps you.

希望这对你有帮助。

回答by Shah Ghafoori

First of all , please use proper HTML for your form by defining labels:

首先,请通过定义标签为您的表单使用正确的 HTML:

HTML

HTML

<label for="firstname">First Name</label>

CSS:

CSS:

form label{
  font-weight:bold;
}

Add any additional style to the css. You can use a class in your form if you have more than one form.

向 css 添加任何其他样式。如果您有多个表单,则可以在表单中使用一个类。

回答by Morfie

If you are unable to change your HTML markup and actually use labels, or spans, or other tags to wrap your labels, then you'd have to do something like:

如果您无法更改 HTML 标记并实际使用标签、跨度或其他标签来包装标签,那么您必须执行以下操作:

fieldset { font-weight: bold; }
fieldset * { font-weight: normal; }