0
Example:
I have the following button and would like to add the property :hover
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
</style>
</head>
<body>
<div class="botaoDesloga">
<button type="button" class="btn btn-danger btnSair" title="Sair" id="divBtnSair" style="background-color: #4d004d; border-color: #4d004d;"> <i class="fa fa-power-off"></i> </button>
</div>
</body>
</html>
But if I inspect the element, the browser tools give me the following options:
My doubts are:
When there is ID for the element and class, I use which of the two ?
When the element is inside a DIV, I use the ID of the div ?
How do I know when to wear .algumCoisa
or algumaCoisa#OutraCoisa
to start the css of which ?
Just a hint, avoid always using ID to put css style in the element, always prefers to class, because with ID vc creates a very strong class and then can only change the style of the element using ! Import. So avoid this
.algumaCoisa#OutraCoisa
preferably for that reason:.algumaCoisa.OutraCoisa
and in the elementclasse="algumaCoisa OutraCoisa"
– hugocsl