I am learning psd to html and starting from scratch but I cannot get a div to apply my style.
I have the following for my div in styles.css
div header header-text
{
top:25px;
left:54px;
font-size:30pt
font-family: 'Roboto', sans-serif;
font-weight: bold;
}
This is my html
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="css/style.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="header">
<div class=header-text">100+ Years Of Combiend Expierence</div>
<div class="header-logo"></div>
</div>
</body>
</html>
Are there any good plugins out their that would get the bare bones style sheet setup.
3
Answers
Answer
Your selectors are wrong. The correct selectors would be:
or forgo the 1st div element selector completely, and just have:
Some more context on the subject:
In the example above:
div
is an element selector &.header
.header-text
are class selectors.The common selector types you’ll most likely encounter (but not limited to) are:
Also…
In CSS the spacing between your classes/selectors matter. Thus in your html:
header
class is on the topdiv
, thus you’d needdiv.header
to target it.header-text
in a child element. Thus you’d need a space, then the class name (or whatever child selector), resulting in a final selector combo/group ofdiv.header .header-text
.To visualize the above:
Have a look at this CSS cheat sheet to see what other options you have available at you disposal, also read up on CSS specificity to make sense of it all.
You need to read about the selectors. If you want to select an item by class, put it.
Just use apply written CSS for classes, therefore you must use . (dot) before html tags and not space between div and header class:
div.header .header-text