Search code examples
htmlcssanchorstylesheet

HTML5 depreciated <a name= in favor of CSS3 id : do i have to


Привет

HTML5 depreciated ' <a name= ' in favor of CSS3 id. Do i have to define every 'anchor id' in a stylesheet?

example of how i'm interpreting what w3c is 'saying'.
<p id="SomeName">Some Text, blah, blah</p>
-or-
<p><span id="SomeName"></span>The <P>aragraph Text, blah, blah... </p>

So, do i have to define ' id="SomeName" ' in either head <style or a linked stylesheet?
#SomeName {
color:black;
font-family: Arial, Helvetica, ;
etc...
}

and repeat this for every 'internal link' , 'name' anchor i want to create? This, like most everything in CSS3 and HTML5 that is supposed to be 'better' seems to be a huge pain in the.... : )

Or,,, do i just 'lie' and label anything i want an 'id' ( <h1 id="MadeupID"> ) without having to describe the ID in style?

Sorry, but i'm not very good with words, so i hope this is enough to go on.
Thanks in advance, Спасибо,
Landis.

ps, i've found many articles, both here and on the interweb, but none are clear as to whether or not the id needs to be defined in stylesheet or styled in anyway.


Solution

  • HTML5 depreciated 'name'

    The name attribute for anchor targets was deprecated in XHTML.

    in favor of CSS3 id.

    No, in favour of HTML's id attribute.

    So, do i have to define id="SomeName in either head style or a linked stylesheet?

    No, you don't have to style anything you don't want to style.

    Or,,, do i just 'lie' and label anything i want an 'id' ( <h1 id="MadeupID"> ) without having to describe the ID in style?

    Not styling something isn't a lie.

    The id attribute provides a way to identify an element. That identification can be used by CSS selectors, by JavaScript, by URL fragment identifiers, and a few other things. It doesn't have to be used at all.