Attributes

class, href, src, alt, height, width, style
FaceBook
img

Here is Style, color red.

Here title Attribute.


class attribute

class

Multiple HTML elements can share the same class. The 'class' attribute is often used to point to a class name in a style sheet. It can also be used by a JavaScript to access and manipulate elements with the specific class name. The class attribute can be used on any HTML element. The class name is case sensitive! To create a class; write a period (.) character, followed by a class name. Then, define the CSS properties within curly braces {}. HTML elements can belong to more than one class. To define multiple classes, separate the class names with a space, e.g. <div class="city main">. The element will be styled according to all the classes specified. Different HTML elements can point to the same class name.

            <script>
                const x = document.getElementsByClassName("dark");
                // x = night 
            </script>
<div class ="dark"> night </div>

id attribute

id

Multiple HTML elements can share the same class. The 'class' attribute is often used to point to a class name in a style sheet. It can also be used by a JavaScript to access and manipulate elements with the specific class name. The class attribute can be used on any HTML element. The class name is case sensitive! To create a class; write a period (.) character, followed by a class name. Then, define the CSS properties within curly braces {}. HTML elements can belong to more than one class. To define multiple classes, separate the class names with a space, e.g. <div class="city main">. The element will be styled according to all the classes specified. Different HTML elements can point to the same class name.

            <script>
                const x = document.getElementsByClassName("lion");
                // x = night 
            </script>
<div id ="lion"> night </div>


Back to