-1

Empty HTML elements (i.e. elements having no content and no closing tag, like br/hr or any other HTML elements which I'm not aware of) can have attributes in the latest HTML5 standard?

Somebody please explain me in simple and easy to understand language.

unor
  • 92,415
  • 26
  • 211
  • 360
PHPLover
  • 1
  • 51
  • 158
  • 311

3 Answers3

3

Yes. Example: The <hr> tag can be modified to move the line around or change its length.

<hr width="50%" align="right">
Biffen
  • 6,249
  • 6
  • 28
  • 36
  • Thanks for your answer but what about br and any other tags present that might present in HTML? – PHPLover Aug 17 '16 at 02:38
  • The attributes `width` and `align` are [non-conforming](https://www.w3.org/TR/2014/REC-html5-20141028/obsolete.html#non-conforming-features) for `hr` elements in HTML5. – unor Aug 22 '16 at 21:52
0

They can For example
tag supports global HTML attributes. You can check the attributes of html tags in W3school site. Here is the one for br: http://www.w3schools.com/tags/tag_br.asp

(Check out the Global Attributes and/or Event Attributes)

Sparrow
  • 2,548
  • 1
  • 24
  • 28
0

You can easily check yourself which attributes an HTML5 element can have. In short:

  1. Visit the HTML5 specification.
  2. Search for the element under the "Table of Contents" (section 4).
  3. For each element, see the attributes listed under "Content attributes".

In case of br and hr, they can have the global attributes (class, id, lang etc.).

Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360