More Subjects
Groups
[Name of the Writer]
[Name of the Institution]
Groups
Main Post
Groups are used in Cascading style sheet CSS to reduce the code redundancy. It is a technique to apply declarations at one time to all the CSS selectors in the document instead of assigning attributes to every tag one by one. For example, a developer wants to apply same font color, size, and family in a document to different headers they will only write the CSS selector and will apply that style attributes to all the headers. Grouping in CSS helps in reducing the size of the code and makes it more comfortable for other developers to understand the code (Robertson, 2001). Here is the example in which grouping is used for different headers to apply the same attribute to all.
Normally code is written like this for applying style one by one to each header
h1 { font-color: red; font size: 20px; font-family: arial}
h2 { font-color: red; font size: 20px; font-family: arial}
h3 { font-color: red; font size: 20px; font-family: arial}
Using grouping
h1, h2, h3 { font-color: red; font size: 20px; font-family: arial}
The above codes clearly represent the difference created by grouping. The code which was written in three different lines has been converted into a single line which helped in reducing the size of the code.
Follow up (1)
Selectors are used in CSS for styling content of a web page. There are three types of selectors in CSS which include id selector, element selector, and class selector. Selectors allow the developers to save more space within HTML code. It is important to note that different headers can be used with each other for styling.
Follow up (2)
The class selector is used in CSS to select the elements using class attribute. The id selector is used in CSS to select elements by looking at the id attribute of HTML element. The element selector is used in CSS to select the HTML element using element name. The class selector is denoted by ‘#', id selector is denoted by ‘.' and element select is written simply without any special character.
References
Robertson, A. (2001). Cascading style sheets: The difinitive guide. Technical Communication, 48(2), 213-214. Retrieved from https://search.proquest.com/docview/220960381?accountid=41759
More Subjects
Join our mailing list
© All Rights Reserved 2024