104 Css - 022142 - 033955 PDF
104 Css - 022142 - 033955 PDF
Local styles
Also known as inline. This form is defined within your
HTML tags/elements. It’s mostly used to style specific
elements in your code.
<html>
<head>
<title>Cascading Style
Sheets</title>
</head>
<body>
<p style = "font-family: sans-
serif;
font-size: 1.2em
font-style: italic;">
This paragraph is an example
of a local style.
</p>
<p>This is an Unaffected
paragraph</p>
</body>
</html>
This code snippet edits the font of the p tag within
the body. However, it only changes the contents of the
first p tag. The second p tag maintains the webpage’s
default style.
By using the style tag in the HTML element p, we’re
able to change the font, font-size, and style only for the
first p. As for the second p element it retains its default
style.
Page-Level styles
Page-level styles are defined at the header area of the
HTML file. All similar tags, whether elements members
of the class or ID selector within the body of the HTML
will undergo the changes at once. An ID selectors can
only identify one element each while Class selectors
can identify more than just one at a time.
<html>
<head>
<title>Cascading Style
Sheets</title>
<meta charset="utf-8">
<style type="text/css">
body{
color: yellow;
background-color: red;
}
p{
color: red;
background-color: yellow;
}
</style>
</head>
<body>
<h1>Heading</h1>
<p>This paragraph has been
styled using page level styling.</p>
</body>
</html>
This time around we defined the style within
the head HTML tags. By doing so the elements defined
in the style tags will automatically adopt the style
defined for them. This means that all p elements on the
page will have a color red and a background-color of
yellow.
The body on the other hand will have a yellow color
and a background-color of red. Developers can
implement this when trying to give the webpage a
different or vibrant theme where the background body
and paragraphs complement each other to give an
appealing look
External Styles
The styles used for the webpage are located in a
completely different file. This other file purely
contains CSS code and is saved with a .css extension.
The .HTML file is linked to the .css file that can be
imported to modify the webpage style.
When developing a website with multiple pages this
styling usually comes in handy. This is due to the fact
that just one CSS file can be implemented on multiple
pages making it easier to maintain uniformity.