<article>
HTML <article> Tag
The <article> tag is one of the HTML5 elements. It is used to define an independent, self-contained content. An article should have its own meaning and be easily differentiated from the rest of the web page content.
The <article> element can include:
blog entry
forum post
news
comment
In the case where the <article> element is nested, the internal element represents an article that is related to the external element.
You can provide the author information of the <article> element by the <address> element. But take into account that it will not apply to nested <article> elements.
Multiple <article> tags can be used in one HTML document.
Headers from <h2> to <h6> can be nested inside the <article> tag. If the <h1> tag was not used before, then its placement is allowed.
The publication date and time of the <article> tag can be described using a <time> element with a datetime attribute.
Syntax
Syntax
The <article> tag comes in pairs. The content is written between the opening (<article>) and closing (</article>) tags.
Example of the HTML <article> tag:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<article>
<h1>Title of the article</h1>
<p>Text of the article</p>
</article>
</body>
</html>
Result
Example of the HTML <article> tag in the HTML<section> tag:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<section>
<h1>Articles about flowers</h1>
<article>
<h2>Roses</h2>
<p>Rose – the queen of flowers - is the object of worship and ardent love. Since time immemorial, the rose has been the object of worship and admiration.</p>
</article>
<article>
<h2>Lilies</h2>
<p> Lily - an amazing beauty flower, one of the most ancient among a variety of bulbous plants. </p>
</article>
</section>
</body>
</html>
Attributes
Attributes
The <article> tag supports the Global Attributes and the Event Attributes.
How to style <article> tag? Common properties to alter the visual weight/emphasis/size of text in <article> tag:
CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit. CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element. CSS font-size property sets the size of the font. CSS font-weight property defines whether the font should be bold or thick. CSS text-transform property controls text case and capitalization. CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style.
Coloring text in <article> tag:
CSS color property describes the color of the text content and text decorations. CSS background-color property sets the background color of an element.
Text layout styles for <article> tag:
CSS text-indent property specifies the indentation of the first line in a text block. CSS text-overflow property specifies how overflowed content that is not displayed should be signalled to the user. CSS white-space property specifies how white-space inside an element is handled. CSS word-break property specifies where the lines should be broken.
Other properties worth looking at for <article> tag:
CSS text-shadow property adds shadow to text. CSS text-align-last property sets the alignment of the last line of the text. CSS line-height property specifies the height of a line. CSS letter-spacing property defines the spaces between letters/characters in a text. CSS word-spacing property sets the spacing between words.