📜  如何在HTML中更改字体大小

📅  最后修改于: 2020-11-04 01:00:21             🧑  作者: Mango

如何在HTML中更改字体大小

在HTML中,我们可以使用以下不同方式来更改任何文本的大小:

  • 使用HTML标签
  • 使用内联样式属性
  • 使用内部CSS

使用HTML标签

注意:HTML 5不支持字体的Size属性,因此我们必须使用内联样式属性和内部CSS选项来更改文本的大小。

如果我们想使用要在网页上显示的Html标签更改文本的大小,我们必须遵循以下步骤。使用这些步骤,我们可以轻松地更改任何文本的大小:

步骤1:首先,我们必须在任何文本编辑器中键入Html代码,或在文本编辑器中打开要使用Html标记更改字体大小的现有Html文件。


   
    
   
Change the text Size Using HTML tag


 
JavaTpoint   
Html Tutorial
How to Change the Font size in Html

步骤2:现在,将光标移动到我们要更改其大小的文本的开头。然后,在该位置键入Html标签。

 Single Line text and statements

步骤3:然后,我们必须在要更改其大小的文本结尾处关闭字体标签。

 Single Line text and statements 

步骤4:现在,我们必须添加名称为“ size”的字体标签的属性。因此,在开始标记内键入Size属性。然后,我们必须提供要在文本上使用的大小。我们可以将size的值设置为1到7。因此,请按照以下块中的说明在Size属性中键入数字。


   
    
   
Change the text Size Using HTML tag


 

JavaTpoint   
Html Tutorial
How to Change the Font Size.

步骤5:最后,我们必须将HTML代码保存在文本编辑器中并运行代码。执行后,我们将在浏览器中看到输出。以下屏幕截图显示了上述Html代码的输出:

使用内联样式属性

如果要使用将在网页上显示的内联样式属性来更改文本的大小,则必须遵循以下步骤。使用这些步骤,我们可以轻松地更改文本大小。

步骤1:首先,我们必须在任何文本编辑器中键入HTML代码,或者在文本编辑器中打开要使用style属性更改文本大小的现有HTML文件。


   
    
   
Change Size using style attribute


 
This page helps you to understand how to change the Size of a text/font.
And, this section helps you to understand how to change the text or font size using the style attribute.


步骤2:现在,将光标放在我们要更改其大小的文本的开头。然后,在任何元素中键入内联样式属性。在这里,我们使用

(段落)标签:

Any Text whose font we want to Change

步骤3:在这一步中,我们必须指定大小。因此,在style属性的font-size属性中键入size。

Any Text whose font we want to Change

步骤4:然后,我们必须在要更改其大小的文本结尾处关闭元素。

Any Text whose font we want to Change

步骤5:最后,保存HTML代码,该代码使用CSS样式属性更改文本/字体大小。


   
    
   
Change Size using style attribute


 
This page helps you to understand how to change the Size of a text/font.

And, this section helps you to understand how to change the text or font size using the style attribute.

以下屏幕快照显示了以上代码的输出:

使用内部CSS

如果要使用将在网页上显示的内部级联样式表来更改文本或字体大小,则必须遵循以下步骤。使用这些步骤,我们可以轻松地更改任何文本的大小。

步骤1:首先,我们必须在任何文本编辑器中键入HTML代码,或者在文本编辑器中打开要使用内部CSS更改文本大小的现有HTML文件。


   
    
   
Change Size using Internal CSS


 
This page helps you to understand how to change the Text or Font Size.
In this Section, we used the internal CSS for changing the text size 


第2步:现在,我们必须将光标放在Html文档的head标签中,然后在

步骤3:现在,我们必须在要更改其大小的文本之前键入定义的元素选择器。


   
    
   
Change Size using Internal CSS



 
This page helps you to understand how to change the Text or Font Size.

In this Section, we used the internal CSS for changing the text size.

以下屏幕快照显示了以上代码的输出: