3 Replies - 258 Views - Last Post: 28 August 2017 - 12:40 AM

#1 dbranch531  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 12-June 17

p[attribute^ = "bacon"] not affecting element

Posted 25 August 2017 - 03:48 PM

I am trying to learn HTML/CSS and can't figure out why this paragraph element won't change to red.

MY HTML CODE:

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>nomad: programmer</title>
    <link rel="stylesheet" href="main.css" />
</head>


    <p name="baconburger">This is a paragraph.</p>
    <p>Another paragraph.</p>
    <p>And another one.</p>


</html>



MY CSS CODE:
p[name^ = "bacon"] {
    color:red;
}



Any suggestions?

UPDATE: I've discovered how to make it work. Less spaces in the CSS. I'm used to Java so I didn't think it cared much about whitespaces.

Is This A Good Question/Topic? 0
  • +

Replies To: p[attribute^ = "bacon"] not affecting element

#2 smendoza88  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 96
  • Joined: 13-July 11

Re: p[attribute^ = "bacon"] not affecting element

Posted 25 August 2017 - 04:16 PM

you could have used a CSS Class too.
Was This Post Helpful? 0
  • +
  • -

#3 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4136
  • View blog
  • Posts: 13,051
  • Joined: 08-June 10

Re: p[attribute^ = "bacon"] not affecting element

Posted 28 August 2017 - 12:37 AM

the name attribute is not valid on paragraphs.
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • the case is sol-ved
  • member icon

Reputation: 6375
  • View blog
  • Posts: 25,756
  • Joined: 12-December 12

Re: p[attribute^ = "bacon"] not affecting element

Posted 28 August 2017 - 12:40 AM

You are also missing the body tag.

If you are following a tutorial that uses the name attribute for a paragraph ditch it immediately and find something valid and recent.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1