Jump to content

Unique element selector no id?

Go to solution Solved by Chris Pratt,

You can use the child combinator (`body > header`) or psuedo-classes like `header:first-of-type` or `header:nth-of-type(1)`.

Hello,so is there a way in  CSS to select without id class name only pseudo-class selectors a unique element for example body header selects only the header of the body the whole page without any headers after that?

I need that for a homework because we are not allowed to change the html and there is no id class name or whatever.

body header{font-weight:bold} 

and not other headers in the body are bold only this one.How?

<body>
	<header>(this one)
    <nav>
    	<header>.....

 

Link to comment
https://linustechtips.com/topic/1333232-unique-element-selector-no-id/
Share on other sites

Link to post
Share on other sites

You can use the child combinator (`body > header`) or psuedo-classes like `header:first-of-type` or `header:nth-of-type(1)`.

CPU: AMD Ryzen 9 9950X3D · Cooler: Noctua NH-D15S Chromax.black · Motherboard: Gigabyte Auros X670 Elite AX · RAM: G.Skill Flare X5 64GB (2 x 32GB) DDR5 6000MHz CL30 · Graphics Card: Zotac NVIDIA GeForce RTX 4070 Super Twin Edge OC 12GB · Boot Drive: 1TB XPG Gammix S70 Blade NVMe SSD · Game Drive: 2TB WD SN850X NVMe SSD · PSU: Seasonic Focus GX V3 1000W 80+ Gold · Case: Fractal Design North Mesh · Monitor: MSI Optix MAG342CQR 34” UWQHD 3440x1440 144Hz · Keyboard: EPOMAKER x Aula F99 Wireless Mechanical Keyboard · Mouse: Logitech G309 Lightspeed Wireless Gaming Mouse

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×