Style attributes in HTML


In the previous article, readers read along with Taimienphi.vn to learn about the paragraph formatting tags in HTML, in the next article below, Taimienphi.vn will introduce you more about the Style attribute in HTML.


To specify and set the format for the HTML element, we use the style attribute. Refer to the following article of Taimienphi.vn to learn in detail the Style attributes in HTML.

Style attributes in HTML

1. Syntax of style attribute in HTML

The style attribute syntax in HTML looks like this:

style style in html

Inside:

– Property is the CSS property.

– Value is the CSS value.

2. Background-color property

Properties background-color In the CSS used to define, set the background color for an HTML element.

For example: In the example below we set the background color for the page to blue:

style style in html 2

The result returned after applying the background-color property looks like this:

style style in html 3

3. Color attribute

Use properties color in CSS to specify text color for HTML elements.

For example: The following example illustrates how to use the color attribute to specify text color for an HTML element.

style style in html 4

The result will look like this:

style style in html 5

4. Font-family attribute

Use properties font-family in CSS to specify the font used for the HTML element.

For example: In this example we will use the font-family property to specify the font to use for the HTML element.

style style in html 6

The result will look like this:

style style in html 7

5. Font-size attribute

Properties font-size in CSS determines the font size for the HTML element.

For example:

style style in html 8

The result returned after applying the font-size attribute, the HTML element looks like this:

style style in html 9

6. Text-align attribute

Properties text-align in CSS is used to align text horizontally for HTML elements.

For example:

style style in html 10

The result returned after applying the text-align attribute, the HTML element looks like this:

style style in html 11

7. Style attributes in HTML

– Use properties style for formatting HTML elements.

– Use properties background-color Set background color for HTML elements.

– Use properties color to set the text color for an HTML element.

– Use properties font-family to specify the font for the HTML element.

– Use properties font-size to specify the font size for the HTML element.

– Use properties text-align to align the text for the HTML element.

The above article Taimienphi.vn has just introduced you to style attributes in HTML. In addition, if you have any questions or questions, you can leave your comments in the comment section below the article.

https://thuthuat.taimienphi.vn/thuoc-tinh-style-in-html-49962n.aspx
In the next articles, Taimienphi.vn will introduce you more about the HTML format tags.

.

Add a Comment

Your email address will not be published. Required fields are marked *