Skip to content
CodeKruPro

CSS Attribute Selectors

11/70

CSS Attribute Selectors

CSS attribute selectors let you match elements based on their attributes:

  • [attr='value'] — exact match
  • [attr^='value'] — starts with
  • [attr$='value'] — ends with
  • [attr*='value'] — contains

On the Text Fields page:

<input type="text" id="lastNameWithPlaceholder"
       name="lastName" placeholder="Enter your last name...">

Task:

  1. Navigate to https://testkru.com/Elements/TextFields
  2. Find an input whose name starts with last using [name^='last']
  3. Print its placeholder using getAttribute('placeholder')
  4. Find an input whose placeholder contains last name using [placeholder*='last name']
  5. Print its ID using getAttribute('id')

Expected output:

Placeholder: Enter your last name...
ID: lastNameWithPlaceholder