I’ve been using CSS and HTML for this and im trying to copy exactly whats on this image here
Below is what i’ve tried doing by using multiple h1 but then I searched up how to have multiple h1’s and it’s advised to generally not do that
h1
{
border : 0px none blue ;
width : 1000px ;
}
<!DOCTYPE HTML>
<html lang = "en">
<head>
<meta charset ="UTF-8">
<title>Headings!</title>
<style>
h1 {color : Red ; background : Blue ;}
h1 {color : Orange}
h1 {color : Yellow}
h1 {color : Green}
h1 {color : blue}
h1 {color : purple}
</style>
<link rel ="stylesheet" href = "heading.css">
</head>
<body>
<h1>This is a heading using h1<h1>
<h1><p style="text-indent:300px;">This is a heading using h1<h1>
<h1><pre>This is a heading using h1</pre><h1>
<h1>This is a heading using h1<h1>
<h1>This is a heading using h1<h1>
<h1>This is a heading using h1<h1>
</body>
</html>
I’ve put them all in the same folder but i will admit I have no idea what i’m doing
4
Answers
In case you do not need this page in production, you can have as many H1 as you want. In case you prepare the web-page for production you should have only one H1
When you make a rule that just targets
h1
tags, it affects them all! The best way to accomplish this is to create a CSS class for each thing you want to do. You should name them in a way that describes what they do, like this:You can use classes to apply different styles to different h1 elements.
Classes can be set in html with the
class=""
attribute and used in css by addressing them with a.
in front of the class name.The following code would be suitable for a production site:
When you are developing a real website, it is not a good practice to have multiple h1 tags on the same page. What you are doing here looks like some kind of practice/learning exercise, so it’s not a problem.
The exercise encourages you to use the same h1 tag as a challenge, so you have to find the way to not use just "h1" selector in the styles section, as those styles will affect every h1 tag.
You can use inline styles, as you did with
(don’t forget to close the
<p>
tag, although you could only use the h1 tag here:<h1 style="text-indent:300px;">This is a heading using h1<h1>
)As a side note, you can center the text of the h1 with
text-align: center
A better way is to use classes:
Then, between the tags, you can use the class selector (with a dot before the name of the class:
Then you can use different classes for each h1 to get what you need, You can chose the class names that you want, the more intuitive, the better.
Another side note: what you wrote between the
<style>
tags, you can write on the CSS sheet that you linked: heading.css