How to Cycle Through CSS Automatically
One of the things you can do with CSS and HTML is to make it so specific that elements, such as <table>, <p> or <img>, in your HTML page automatically cycle through your CSS codes for the purpose of selecting only certain codes to use. This will make it so only the styles you want are applied to your specific HTML elements. To enable this CSS cycling feature, add the class or ID attribute to your HTML elements. To add attributes, you need to open your HTML and CSS pages in your code-editing program.
Instructions
-
-
1
Go to the code view of your CSS page and scroll through it to the line(s) of code you want to apply only to a specific HTML element. Type a relevant word or words — such as “upper_table” for the table at the top of your HTML, with a “.” or a “#” and no spaces just before the CSS code starts. For example:
.upper_table {CSS code here} or #upper_table {CSS code here} -
2
Save your CSS page and go to the code view of your HTML page. Scroll through it to the element you want to apply the CSS code to. Click inside the opening and closing brackets of the element — for example, <p> or <img>, and type in the following text: Replace “upper_table” with whatever word(s) you used in your CSS:
class=“upper_table” (if you used a “.” in your CSS page) or id= “upper_table” (if you used a “#” in your CSS page). -
-
3
Repeat the previous two steps for the rest of the HTML elements you want to apply the CSS codes to and save your CSS and HTML pages. Your HTML elements will now automatically cycle through your CSS codes and only apply the CSS codes with the same class or ID attribute (e.g., “upper_table”).
-
1