Html html代码中的字体大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3881520/
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
font size in html code
提问by tintincutes
<html>
<tr>
<td style="padding-left: 5px;padding-bottom:3px; font size="35;""> <b>Datum:</b><br/>
November 2010 </td>
</html>
is my code correct? i would like to increase the font of the first line. Not sure if i have to put 2 "'s here. and it seems it didn't work.
我的代码正确吗?我想增加第一行的字体。不确定我是否必须在这里放 2 个“。似乎它不起作用。
回答by Good Samaritan
Try this:
尝试这个:
<html>
<table>
<tr>
<td style="padding-left: 5px;
padding-bottom: 3px;">
<strong style="font-size: 35px;">Datum:</strong><br />
November 2010
</td>
</tr>
</table>
</html>
Notice that I also included the table-tag, which you seem to have forgotten. This has to be included if you want this to appear as a table.
请注意,我还包含了 table-tag,您似乎已经忘记了。如果您希望将其显示为表格,则必须将其包含在内。
回答by jimplode
font-size:35px;
So like this:
所以像这样:
<html>
<tr>
<td style="padding-left:5px;padding-bottom:3px;">
<strong style="font-size:35px;">Datum:</strong>
<br/>
November 2010
</td>
</tr>
</html>
Although inline styles are a bad practice and you should class things. Also you should use a <strong></strong>
tag instead of <b></b>
尽管内联样式是一种不好的做法,您应该对事物进行分类。你也应该使用<strong></strong>
标签而不是<b></b>
回答by jknair
you dont need those quotes
你不需要那些报价
<td style="padding-left: 5px;padding-bottom:3px; font-size: 35px;"> <b>Datum:</b><br/>
November 2010 </td>
回答by Stan Rogers
There are a couple of answers posted here that will give you the text effects you want, but...
这里发布了几个答案,可以为您提供所需的文本效果,但是...
The thing about tables is that they are organized collections of labels and data. Having both a label ("Datum") and the value that it labels in the same cell is oh so very wrong. The label should be in a <th>
element, with the value in a <td>
either in the same row or the same column (depending on the data arrangement you are trying to achieve). You can have <th>
elements running either vertically or horizontally or both, but if you don't have heading cells (which is what <th>
means), you don't have a table, you just have a meaningless grid of text. It would be preferable, too, to have a <caption>
element to label the table as a whole (you don't have to display the caption, but it should be there for accessibility) and have a summary="blah blah blah"
attribute in the table tag, again for accessibility. So your HTML should probably look a lot more like this:
关于表格的事情是它们是标签和数据的有组织的集合。在同一个单元格中同时拥有标签(“数据”)和它标记的值是非常错误的。标签应该在一个<th>
元素中,值在<td>
同一行或同一列中(取决于您要实现的数据排列)。您可以让<th>
元素垂直或水平或两者同时运行,但如果您没有标题单元格(这就是什么<th>
意思),您就没有表格,您只有一个毫无意义的文本网格。最好也有一个<caption>
元素来标记整个表格(您不必显示标题,但为了可访问性,它应该在那里)并且有一个summary="blah blah blah"
表标签中的属性,同样是为了可访问性。所以你的 HTML 应该看起来更像这样:
<html>
<head>
<title>Test page with Table<title>
<style type="text/css">
th {
font-size: 35px;
font-weight: bold;
padding-left: 5px;
padding-bottom: 3px;
}
</style>
</head>
<body>
<table id="table_1" summary="This table has both labels and values">
<caption>Table of Stuff</caption>
<tr>
<th>Datum</th>
<td>November 2010</td>
</tr>
</table>
</body>
</html>
That may not be exactly what you want -- it's hard to tell whether November 2010 is a data point or a label from what you've posted, and "Datum" isn't a helpful label in any case. Play with it a bit, but make sure that when your table is finished it actually has some kind of semantic meaning. If it's not a real table of data, then don't use a <table>
to lay it out.
这可能不是您想要的——很难从您发布的内容中判断 2010 年 11 月是数据点还是标签,而且“数据”在任何情况下都不是有用的标签。稍微尝试一下,但要确保当您的表格完成时,它实际上具有某种语义含义。如果它不是真正的数据表,则不要使用 a 对其<table>
进行布局。
回答by MatTheCat
Don't need to quote css attributes and you should specify an unit. (You should use an external css file too..!)
不需要引用 css 属性,您应该指定一个单位。(您也应该使用外部 css 文件..!)
回答by TheFitGeekGirl
<html>
<table>
<tr>
<td style="padding-left: 5px;padding-bottom:3px; font-size:35px;"> <b>Datum:</b><br/>
November 2010 </td>
</table>
</html>
回答by Prateek
just write the css attributes in a proper manner i.e:
只需以适当的方式编写 css 属性,即:
font-size:35px;
回答by Ruel
I suggest you use CSS instead, seems like you're going to repeat those lines later on. But to answer your question:
我建议您改用 CSS,看来您以后要重复这些行。但要回答你的问题:
<html>
<head>
<style type="text/css">
td.randname {
padding-left: 5px;
padding-bottom:3px;
font-size:35px;
}
</style>
</head>
<body>
<table>
<tr>
<td class="randname"> <b>Datum:</b><br/>
November 2010 </td></tr>
</table>
</body>
</html>
回答by Vetle
The correct CSS for setting font-size is "font-size: 35px". I.e.:
设置 font-size 的正确 CSS 是“font-size: 35px”。IE:
<td style="padding-left: 5px; padding-bottom:3px; font size: 35px;">
Note that this sets the font size in pixels. You can also set it in *em*s or percentage. Learn more about fonts in CSS here: http://www.w3schools.com/css/css_font.asp
请注意,这以像素为单位设置字体大小。您也可以将其设置为 *em*s 或百分比。在此处了解有关 CSS 字体的更多信息:http: //www.w3schools.com/css/css_font.asp