I can’t change properties using css

Asked

Viewed 110 times

0

I am learning web development and when trying to do a simple test I could not change font size, background color and other properties. I don’t understand where I’m going wrong.

#tabela{
	font-size: 64px;
	background-color: red;
	padding: 20px;
}
<!DOCTYPE html>
<html>
	<head>
		<title>Campanhas publicitárias</title>
		<meta charset="utf-8">
		<link rel="stylesheet" type="text/css" href="estilo.css">
	</head>
	
	<body>
		<div>
			<img src="imagens/capa.png">
		</div>

		<div>
			<tr id="tabela">
				<td>item1</td>
				<td>item2</td>
				<td>item4</td>
				<td>item5</td>
			</tr>

		</div>
		
	</body>

</html>

Could someone help me understand what I’m doing wrong ?

1 answer

3


The problem is that you have declared a row of a table outside of a table. This is not valid in HTML, but your browser’s HTML interpreter tries to fix errors automatically to keep the page running and as a result its tr that contains the id responsible for the style is deleted, leaving the element without style.

All you need to do is put your tr within a table:

<table>
    <tr id="tabela">
        <td>item1</td>
        <td>item2</td>
        <td>item4</td>
        <td>item5</td>
    </tr>
</table>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.