Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In HTML attributes, When to use a comma, and When to use a space

Tags:

html

<frameset cols="25%,75%"></frameset> <!-- comma -->
<input type="text" form="first second three" />  <!-- space -->
<input type="file" accept="image/gif, image/jpeg" />  <!-- comma -->
<div class="a b c d">   <!-- space -->

so, In HTML attributes, When to use a comma, and When to use a space

like image 766
ph4.6 Avatar asked Sep 18 '25 21:09

ph4.6


2 Answers

Most of the time it just comes to to learning which one to use for which element.

Essentially, you should consider comma-separation as an AND statement, and a space as an OR statement. In <input type="file" accept="image/gif, image/jpeg" />, you want the upload to allow both .gif and .jpeg files. In <div class="a b c d">, you want the declaration to apply to any of the classes.

Note that <frameset> is deprecated in HTML5, so you should avoid using it entirely.

like image 82
Obsidian Age Avatar answered Sep 20 '25 12:09

Obsidian Age


There's no general rule. It depends on the html element/attribute.

Other example:

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
like image 22
Aloso Avatar answered Sep 20 '25 12:09

Aloso