can we set a class name for HTML tag containing some spaces like this
<div class="drag-down drag-here">
this is the body part ..
</div>
.
can we set a class name for HTML tag containing some spaces like this
<div class="drag-down drag-here">
this is the body part ..
</div>
.
If both of these classes are separate then your class attribute can contain these two classes separated by space. But if you are trying to create a class name with SPACE then it is not as per standards and will not work. Even if you try to enter then browser will treat drag-down and drag-here as separate classes and not a single one.
Your way is to specify multiple classes.
This way separates the class names with a space, i.e. <htmlTag class="class1 class2"> or <div class="drag-down drag-here"> allows you to combine several CSS classes for one HTML element.
Naming rules:
A-Z or a-z2.Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"), and underscores ("_")
3.In HTML, all values are case-insensitive
The above rule doesn't mention a space so no space allowed to name a class attribute.
Classes can be whateve you want, but a space means a different class name. In your case, two classes: drag-down & drag-here
No. Class names can not have spaces in between. The space mentioned in your code describes that 2 different CSS classes are added to the element.
Well, the HTML from your question is valid. However, it is interpreted as two seperate class names:
drag-downdrag-herebecause a space seperates multiple class names. Unlike the id attribute, the class attribute can contain multiple values.
So, when using for instance CSS, styling rules targeted at div.drag-down and div.drag-here will both be applied to this element.
Also see the W3C documentation.
<div class="drag-down drag-here">
Means the div has two classes drag-down and drag-here. You can have any number of classes separated by spaces.
You can specify multiple classes, seperated by a space, but a given class name cannot contain spaces.
Please refer to HTML class Attribute
spaces cannot be used! better use an underscore like this:
<div class="drag-down_drag-here">
this is the body part ..
</div>