I have the following code fragment. I would like to change the color to <title>
.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Mi primer CSS</title>
<style>
h1{
color: red;
}
</style>
I have the following code fragment. I would like to change the color to <title>
.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Mi primer CSS</title>
<style>
h1{
color: red;
}
</style>
If what you have in your CSS
is a H1
that will change the color to all h1
that you have in your html
, what you have here is a TITLE so it will not work for you, if you try it that way if it should work
<h1>Mi primer CSS</h1>
You need to structure a little more the code, what you want to see must be inside the body and inside this a h1 It should look like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Mi primer CSS</title>
<style>
h1{
color: red;
}
</style>
</head>
<body>
<h1>TEXTO CON COLOR ROJO</h1>
</body>
</html>
You can also change the color "red" by a hexadecimal value # FF0000 Remember that it is composed by RGB and has values from 0 to F, where F is the most significant value and there are 2 values for each color FF0000 indicates red = FF green = 00 and blue = 00.
I hope it's useful for you.
No text appears because you have nothing inserted in it. You should add a label as <h1>Texto a mostrar</h1>
and so this text could be red.
The <title>
tag must be included in the because it refers to the title of the html page.
First of all, no element within the element can be modified, this is because they are header elements that mostly provide information about the file, I recommend you to see the Platzi Software Engineering Fundamentals Course so that you understand more thoroughly the structure of a file, especially that of an HTML file.
Now, it turns out that you have a style tag where you intend to add a red color to an element using css, this is totally possible as long as the element exists, and since you never create the element, you will not be able to visualize it as is logical.
Well, now, for this to happen you have to create a body to the page, since the header is only to provide information about the file, for that you would do the following:
<!DOCTYPE html>
<html>
<head>
<title>Mi primer CSS</title>
<meta charsert='utf-8'>
<style>
h1 {
color: red;
}
</style>
</head>
<body>
<h1>Mi Primer CSS</h1>
</body>
</html>
As you can see here I inserted some lines, the first is the DOCTYPE very necessary nowadays to work with HTML5 which is the standard act of the HTML. Then I added the body with the body tag as I mentioned, and inside I added the title using the h1 tag.