1 / 5

CSS: Class Attribute

CSS: Class Attribute. BCS-AWD-7. CSS: Definition and Usage. The Class Attribute is used when you want to identify elements that share a common characteristic.

Download Presentation

CSS: Class Attribute

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSS: Class Attribute BCS-AWD-7

  2. CSS: Definition and Usage • The Class Attributeis used when you want to identify elements that share a common characteristic. • The class attribute is mostly used to point to a class in a style sheet. However, it can also be used by a JavaScript (via the HTML DOM) to make changes to HTML elements with a specified class.

  3. CSS: Definition and Usage • To assign an element to a class, add the attribute class=”classname”to the element’s markup tag, where classname is the name of the class. • To apply a style to a class of elements, use the selector .classnamewhere classnameis the name of the class. • To apply a style to an element of a particular class, use the selector elem.classnamewhere elem is the name of the element and classnameis the name of the class.

  4. CSS: Definition and Usage Syntax: <elem class=“classname”>…..</elem> Classname: Specifies one or more class names for an element. To specify multiple classes, separate the class names with a space, e.g. <span class="left important">. This allows you to combine several CSS classes for one HTML element.

  5. CSS: Definition and Usage Class Naming rules: • Must begin with a letter A-Z or a-z • Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"), and underscores ("_") • In HTML, all values are case-insensitive

More Related