占位符中的html元素

占位符中的html元素,html,placeholder,Html,Placeholder,我有这个输入 <input class="form-control input-lg" type="text" placeholder="Name" name="name"> 因为我的表单没有标签,而且我依赖于占位符,所以是否可以像这样放置一个元素 <sup>*</sup> * 这样我可以向用户显示此字段是必需的 我试过了,但没用 有办法吗 我的表格 使用标签: <input class="form-control input-lg" type

我有这个输入

<input class="form-control input-lg" type="text" placeholder="Name" name="name">

因为我的表单没有标签,而且我依赖于占位符,所以是否可以像这样放置一个元素

<sup>*</sup>
*
这样我可以向用户显示此字段是必需的

我试过了,但没用

有办法吗

我的表格

使用标签:

<input class="form-control input-lg" type="text" placeholder="Name" name="name">
<label for="Name">*</label>

*

也可以在占位符文本后添加*。有没有不使用标签的原因?如果您不想使用标签,它们是良好的做法

css代码:

html代码:



你不能使用
*
吗?satpal它不起作用。为此,我只想尝试一些新的更干净的表单。表单没有标签看起来总是更干净,但它不好有很多原因,主要是可访问性,google-like的页面对每个人来说都更容易访问,所以省略标签会影响你的页面排名。先生,我试试这个
.required::before {
    content: "*";
    color:red;
}
<span class="required"></span>
<input class="form-control input-lg" type="text" placeholder="Name" name="name">