CSS with HTML
Let us consider the following code example where we apply various styles to an element.
A journey of a thousand miles begins with a single step
In this example we have used inline css, the problem is that whenever I need to create a similar element, I would have to rewrite all the styling parts with that element. The solution to this is to use internal CSS. Since we are now dealing with CSS, we will need to work with classes. Have a look at this example
This is an example of how css can be used
In the Example above, we have created a
<style> tag and inside that style tag, we have created a class called
.theitstuff. It is important to note, that all CSS class names are accessed by the . specifier.
After that, in the body section, we just gave our element a class attribute with the class name that we created. Now all the style code written for that class will be given to the element.
This is very useful when you have to make changes in multiple elements that are similar.
The webpage above displays an alert. This can be achieved with the following code.
You can see that we have placed a
These files can then be used in the main page by inserting the following tags in the head section.
<link rel="stylesheet" type="text/css" href="filename.css">