更改HTML表单输入字段文本大小

更改HTML表单输入字段文本大小,html,safari,Html,Safari,我有如下html文件: <p> Enter your first name and last name in the following form </p> <form> First name: <input type="text" name="firstname"><br> Last name: <input type="text" name="lastname"> </form>

我有如下html文件:

<p>
    Enter your first name and last name in the following form
</p>
<form>
    First name: <input  type="text" name="firstname"><br>
    Last name: <input type="text" name="lastname">
</form>

在下表中输入您的名字和姓氏

名字:
姓氏:
在CSS中,p标记的文本大小设置为40px


我想将两个文本框的字体大小也设置为40px。

因此请编写一个与它们匹配的选择器

input { font-size: 40px; }

元素
input
textarea
select
不会像您预期的那样继承样式

定义段落样式时,添加
输入[type=“text”]
选择器:

p,
input[type="text"] {
    font-size: 40px;
}

我通常用我的
正文
字体样式来定义它们。

段落中不能有表单。@昆汀这不是首选,但技术上可以,因为它们都是块元素。@iambriansreed-否,这是不允许的…浏览器会在表单的开头终止一个段落。HTML 4说段落在这里只能包含内联元素:
HTML 5说
p
元素的内容模型是(不是流内容)。感谢CSS中的额外专门化,我对此表示感谢。感谢您的帮助,它像预期的那样工作。但我认为@ambriansreed应该得到更具体的认可。