html 属性中使用变量_如何使用HTML属性

html 属性中使用变量

How To Build a Website With HTML 如何使用HTML构建网站

This tutorial series will guide you through creating and further customizing this website using HTML, the standard markup language used to display documents in a web browser. No prior coding experience is necessary but we recommend you start at the beginning of the series if you wish to recreate the demonstration website.

本教程系列将指导您使用HTML(用于在Web浏览器中显示文档的标准标记语言)创建和进一步自定义此网站 。 不需要任何编码经验,但是如果您希望重新创建演示网站,建议您从本系列的开头开始 。

At the end of this series, you should have a website ready to deploy to the cloud and a basic familiarity with HTML. Knowing how to write HTML will provide a strong foundation for learning additional front-end web development skills, such as CSS and JavaScript.

在本系列的最后,您应该拥有一个可以部署到云的网站,并且对HTML有了基本的了解。 知道如何编写HTML将为学习其他前端Web开发技能(例如CSS和JavaScript)奠定坚实的基础。

HTML attributes can be used to change the color, size, and other features of HTML elements. For example, you can use an attribute to change the color or size of a font for a text element or the width and height for an image element. In this tutorial, we’ll learn how to use HTML attributes to set values for the size and color properties of HTML text elements.

HTML 属性可用于更改HTML元素的颜色,大小和其他功能。 例如,您可以使用属性来更改文本元素的字体的颜色或大小,或图像元素的宽度和高度。 在本教程中,我们将学习如何使用HTML属性设置HTML文本元素的大小和颜色属性的值。

An HTML attribute is placed in the opening tag like this:

将HTML属性放置在开始标记中,如下所示:

One common attribute is style, which allows you to add style properties to an HTML element. While it’s more common to use a separate stylesheet to determine the style of an HTML document, we will use the style attribute in our HTML document for this tutorial.

一个常见的属性是style ,它允许您将样式属性添加到HTML元素。 虽然通常使用单独的样式表来确定HTML文档的样式,但在本教程中,我们将使用HTML文档中的style属性。

使用样式属性 (Using the Style Attribute)

We can change multiple properties of an

element with the style attribute. Clear your “index.html” file and paste the code below into your browser. (If you have not been following the tutorial series, you can review instructions for setting up an index.html file in our tutorial Setting Up Your HTML Project.

我们可以使用style属性更改

元素的多个属性。 清除“ index.html”文件,然后将以下代码粘贴到浏览器中。 (如果您还没有按照教程系列进行操作,则可以在我们的教程设置HTML项目中查看有关设置index.html文件的说明。

This text is 40 pixels and green.

Before we load the file in our browser, let’s review each of the parts of this HTML element:

在将文件加载到浏览器中之前,让我们回顾一下此HTML元素的每个部分:

  • h1 is the name of the tag. It refers to the largest-sized Heading element.

    h1是标签的名称。 它是指最大的标题元素。

  • style is the attribute. This attribute can take a variety of different properties.

    style是属性。 此属性可以采用各种不同的属性。

  • font-size is the first property we’re setting for the style attribute.

    font-size是我们为style属性设置的第一个属性。

  • 40px; is the value for the property font-size, which sets the text content of the element to 40 pixels.

    40px;font-size属性的值,该属性将元素的文本内容设置为40像素。

  • color is the second property we’re setting for the style attribute.

    color是我们为style属性设置的第二个属性。

  • green is the value for the property color, which sets the text content color to green

    green是属性color的值,它将文本内容颜色设置为绿色

Note that the properties and values are contained by quotation marks, and that each property:value pair ends with a semicolon ;.

请注意,属性和值包含在引号中,并且每个property:value对均以分号结尾;

Save the file and reload it in your browser. (For instructions on loading the file in your browser, see our tutorial here.) You should receive something like this:

保存文件并将其重新加载到浏览器中。 (有关在浏览器中加载文件的说明,请参见此处的教程 。)您应该收到类似以下内容的信息:

此文本为40像素,为绿色。 ( This text is 40 pixels and green. )

You have now learned how to use the style attribute to change the font size and font color of a text element. Note that certain elements require attributes, such as the element which allows you to add a link to a text or image, and the element, which allows you to add an image to the document. We’ll cover those two elements in the next tutorials and learn about additional attribute usage for

你可能感兴趣的:(css,html,python,javascript,java)