1. More About CSS We’ve seen how CSS styles can be specified as an attribute of
ID: 3573085 • Letter: 1
Question
1. More About CSS
We’ve seen how CSS styles can be specified as an attribute of an HTML element:
<p style=”text-align:center”>This text is centered!<p>
In this case, the style attribute indicates that the text of this paragraph should be centered instead of the default left alignment. But this style applies only to this single paragraph. What if we want to establish a style for all paragraphs on the page?
CSS styles can also be expressed in the head section of the HTML document. For example, we could put the following style tag (not an attribute this time, but a tag) between the <head> and </head> tags:
Please provide an example…
(please answer in essay form)
Explanation / Answer
To apply the CSS style to all the paragraphs of the page we can add style tag inside head tag and this will apply to all paragraphs something like below
!DOCTYPE html>
<html>
<head>
<title>Styling</title>
<style>
p {
color: brown;
}
a {
color: pink;
}
</style>
....then continue to whatever you want to include in your html page
There is another way to add style not only to whole page but to multiple pages, and this is called external style where you create a seperate CSS class and then add that your HTML page , eg
Css file
....
p {
color: brown;
}
a {
color: pink;
}
Now refer to this css file in your html
<!DOCTYPE html>
<html>
<head>
<title>styling</title>
<link rel="stylesheet" href="style.css">
...
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.