If an HTML tag has an ID, you can add CSS rules that apply to that specific tag, even in an external style sheet! To do this, simple type a pound sign (#), followed by the id, followed by your rules in the normal curly brackets.
For example, your HTML code may look something like:
In this case, your CSS could look something similar to:
NOTE: every ID is unique, meaning you cannot use an ID on numerous HTML tags to add CSS rules to multiple different tags. We will discuss this further on the following page.
Keep in mind that although it is not incorrect to adjust CSS of an HTML element based on the ID of that element, it is not commonly practiced. Many people will use an inline style for that specific tag, instead. However, another alternative is using the "class" attribute on your HTML tag. This HTML attribute, along with the CSS Class selectors, is discussed on the next page.
Previous Next